Form Class Query
Hi,
Looking to use the Editor with a texarea field.
It's not working at the moment. Here's my code:
echo $Form->textarea_field('courseDeets','Details',isset($details['courseDeets'])?$details['courseDeets']:false,"description",true);
I'm not sure I understand the context, can you post more information about what you are trying to do plus your Diagnostics Report and template.
Hi Rachel,
In your docs for the Form class in the API, it says that I can use an editor with the textarea field. That's what I'm trying to do!
Here is my diagnostics report:
and the file that I'm using:
To use an editor, it's just a case of getting the correct class onto the textarea. The JavaScript then does the rest.
Hi Drew,
Are you able to explain what you mean? I followed the docs (at least, I thought I had), by using a boolean for the last parameter of the
textarea_field
call.Thanks, Harry
By default the field will use the default editor, which is legacy behaviour.
You can pass in a tag object so that a bunch of options can be set. If you have a template from the user, you can use that tag - if not you can build your own:
Hi Drew,
I'm using this code:
(I've also used <perch:content instead of shop, but with no difference in the outcome).
Here's what's being output:
I'm looking for the editor with the top bar where you can choose Bold, Italic, Underline etc.
Currently, the textarea field is just a textarea field, with no editor.
Thanks, Harry
The output looks correct to me. Is it otherwise working like you'd expect?
Hi Drew,
No - it's outputting just a textarea without the editor.
Thanks, Harry
Right, but doesn't it work otherwise?
The textarea works.
However, I need it to be a textile (or editor, whichever has the WYSIWYG).
Ok, I'll see if I can figure out a solution.
Hi Drew,
Did we get any further with this?
Thanks, Harry
No, without a template there's no field types to kick the JavaScript into action.
So how would you suggest that I get this to work?
I'm following your docs, as far as I'm aware.
Hi Drew,
In your docs for the $Form API Class, the
textarea_field
method is documented like this:I'm trying to pass this:
The boolean
useEditor
parameter, which I've set to 'true', doesn't seem to be making a difference - any ideas?Just looking to chase this issue a little, as I do need to deliver this to a client.
Thanks!
You need to use a template to get all the options from the field types. Either that or manually add the editor through a UI plugin.
Hi Drew,
Thanks for the help.
How would I call a template in at that point? Here's my whole course.edit.post.php file:
After the work done between us earlier in this thread, this section:
is the bit that I need to be a WYSIWYG editor.
Could you let me know why this isn't working? I think I saw a call to
get_fields_from_template
somewhere in these files - would that be a resolution?I'd suggest looking at the sample app, because this has worked examples of how to do all these things. Particularly, look at
modes/edit.pre.php
andmodes/edit.post.php
.A basic edit form would be:
This will build the form using proper field types based on the template in
$Template
.Hi Drew,
Thanks for the help - I moved on to looking at the comments app.
I've found that the problem if I put the textile editor in is that it outputs the field as a dynamic field, whereas I need it as a static field.
I'll jump back onto this thread if I have any issues.
Hi Drew,
No real progress made, unfortunately!
The main issue seems now to be that I can't get the textarea field,
'courseDeets'
, to feed through as a static field. It keeps feeding through as a dynamic field, regardless of what I change.Any ideas? Thanks!