[html-formfu] Re $form->get_field with dynamic insert elements
Carl Franks
fireartist at gmail.com
Fri Nov 2 10:00:25 GMT 2007
On 01/11/2007, kewei xiao <kewei.xiao at nald.ca> wrote:
>
> YAML part:
> - type: Block
> tag: fieldset
> id: copyright
> elements:
> - type: Block
> tag: legend
> content: Copyright
> - type: +NSSAL::Activities::Form::Element::CopyRightStatus
> container_tag: ~
> id: status_list
> name: status_list
> attributes_xml: { onchange: "addInfo(this.id)" }
> attributes:
> class: radiogroup
> $form->get_field( 'resources' )->default(
I can't see a field called 'resources' in that YAML config, where's
that being created?
> When I click a radio button, the textarea will pop up.
>
> when I go to update page, if the radio button is checked by default, i
> want that textare to be pop up and with content in it.
When doing this sort of thing, I find it much easier to:
* view the basic FormFu form in a browser
* use the browser to "save as html" or "save as webpage"
* edit that static page, testing it in the browser
* once you've got that working, reverse-engineer it back to HTML-FormFu
When you say "pop up", do you mean the textarea should be inserted
into the page, between existing fields?
If so, I can't really help you with that - I don't even attempt to
write cross-browser JavaScript anymore, I just use Dojo.
You can find an example of something similar in the Dojo::Repeatable
element here:
http://html-formfu.googlecode.com/svn/trunk/HTML-FormFu-Dojo/lib/HTML/FormFu/Element/Dojo/Repeatable.pm
I think the basic steps you need are:
* the textarea markup should be in a JS string
* this string needs to be built into DOM nodes
* you insert those DOM nodes into the appropriate place in the document
* you either need a body onload event, or JS within the body to check
the radio button when the document is first loaded
* you also need an event handler on the radio button, to handle it
being checked after page-load
If you need more help than this, I think you're going to need to take
it to a JS forum.
btw - it's not a big deal, but your example YAML...
---
elements:
- type: Block
tag: fieldset
id: copyright
elements:
- type: Block
tag: legend
content: Copyright
- type: +NSSAL::Activities::Form::Element::CopyRightStatus
Could be written much more succinctly as:
---
auto_fieldset:
id: copyright
legend: Copyright
elements:
- type:+NSSAL::Activities::Form::Element::CopyRightStatus
Cheers,
Carl
More information about the HTML-FormFu
mailing list