Forum
Creating an app, using Form API for admin UI - textarea problem
I am playing around with developing an app - using the sample app as a starting point.
I'm using static fields for the admin UI, but a textarea field I've configured isn't showing the markitup editor.
My edit.post.php contains:
echo $Form->textarea_field('notes', 'Notes', $details['notes'], 'textile s autowidth', true);
Checking the source for the page correctly gives:
<div class="field ">
<label for="notes" class="">Notes</label>
<textarea id="notes" name="notes" class="text textile s autowidth large markitup textile" rows="6" cols="40"></textarea>
</div>
But the markitup editor does not display on the admin page. Neither does the textile help link next to the textarea.
Looking at the source for the Pages area in the admin, it appears that the following javascript and css files are missing from my admin page:
<script type="text/javascript" src="/new-gaffer/addons/plugins/editors/markitup/jquery.markitup.js"></script>
<script type="text/javascript" src="/new-gaffer/addons/plugins/editors/markitup/settings.js"></script>
<script type="text/javascript" src="/new-gaffer/addons/plugins/editors/markitup/image_upload/image_upload.js"></script>
<script type="text/javascript" src="/new-gaffer/core/assets/js/jquery.form.min.js"></script>
<script type="text/javascript" src="/new-gaffer/addons/plugins/editors/markitup/config.js"></script>
<link rel="stylesheet" href="/new-gaffer/addons/plugins/editors/markitup/skin.css" type="text/css" />
<link rel="stylesheet" href="/new-gaffer/addons/plugins/editors/markitup/style.css" type="text/css" />
<link rel="stylesheet" href="/new-gaffer/addons/plugins/editors/markitup/image_upload/image_upload.css" type="text/css" />
Any advice on how to configure the admin page correctly?
Are you using any field types, or is it just hard coded fields?
Just hard-coded fields - text_fields and the one textarea_field.
The editor script/CSS gets included by the field types - the
textarea_field
is the underlying primitive. I would seriously recommend using a template if you want features like editors and textile or markdown - the field types will then make all that magic happen for you.In your
pre
file:In your
post
file:Hi Drew,
configured as recommended - the admin form displays fine, with full markitup editor. However, the textarea_field is failing on save - an array is being passed to the database instead of a string. The array contains the text from the form, as 'raw' and 'prcoessed'. So I'm guessing it needs some json encoding before being passed to the database?
In the sample app, you do this for thingDynamicFields - I'll see if I can hack around with that and get it working with my current table...
Yes, you'll want to store the full structure.
Drew, just to let you know this is all working now as expected.
The sample app threw me a little bit - the reference to "dynamicFields" made me think I had to use static fields (because I have one column in my database for one field). As it is, I'm using a "dynamicField" to just store one entry. Now I've got my head round that, it will make things a lot easier in the future!
Cheers.