We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Has anyone written a custom field extension that uses the formatting dropdown?

Development and Programming

Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

The title says it all. I have a custom field which is basically trying to replicate a textarea, but give that textarea a class so I can target it with some jQuery. The publish_form_field_unique hook seems to wipe out the whole form field area - taking the formatting dropdown and other things with it (smileys, glossary). But in my case, I would like the fomatting dropdown. I was able to hack it in, but it does not save the changes I make.

Rather than reinventing the wheel, I’d like to know if anyone has already made use of the formatting dropdown with a custom field.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

I’ll take that as a “no”.

Let’s go a bit further. I’ve managed to get the formatting dropdown under my custom field. I can make a selection - say, switching from Xhtml to Textile - but it won’t save my selection. How is it I can add something to the field and save that, but if I switch the pulldown, it just pops back to what it was? Am I missing a hook?

I’ve attached a pic of a sample field from my Markitup extension to help illustrate what I’m talking about.

I basically ripped the text_formatting_buttons() function out of cp.publish.php (line 4980), stripped it of spellcheck, glossary, and smileys, put it into my extension as a private function (_text_formatting_buttons()) so that it would give me the formatting dropdown. For the field shown in the attached pic, the field format dropdown code looks like this:

<div class='xhtmlWrapper' >

<span class='lightLinks'></span>

<span class='xhtmlWrapperLight'>Formatting:</span>

<select name='field_ft_28' class='select' >
<option value='br'><br /></option>
<option value='markdown'>Markdown</option>

<option value='textile' selected='selected'>Textile</option>
<option value='xhtml'>Xhtml</option>
<option value='none'>None</option>
</select>
 
</div>

It is grabbing the right field id for the select name. Can anybody help me figure how how I can change that selection and have it save like a “real” textarea field? This is pretty much the last step so I can release the latest version of MD Markitup. Thanks.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.