[html-formfu] Increment id on block elements
Stephen Shorrock
stephen.shorrock at googlemail.com
Mon Dec 7 13:02:52 GMT 2009
On Mon, Dec 7, 2009 at 11:50 AM, Carl Franks <fireartist at gmail.com> wrote:
> 2009/12/7 Stephen Shorrock <stephen.shorrock at googlemail.com>:
>> Dear list,
>>
>> FormFu has been excellent at handling and displaying my forms, I've
>> found a single call to render the form fantastic. However I've come up
>> against some limitations which may not allow me to render a form as
>> simple as this.
>>
>> I have a repeatable within which I have a number of block elements, and fields.
>>
>> By creating a custom Block element is there something I could override
>> / modify to increment the field id? within the render I wish these
>> block element to have the row number appended to their ids cf field
>> elements. Indeed I'd like to access these elements via the form
>> object in my controller, so I imagine that I would also need to have
>> a name attribute associated with them but this will render my XHTML as
>> invalid.
>
> Hi Stephen,
>
> Could you give an example of exactly what you'd like the output xhtml
> to look like - including the field and block IDs ?
>
> Cheers,
> Carl
>
Hi Carl,
Sure, I've hacked out of my code an example 9removed a few filters
and other elements). In the specific case that I'm working on the
block element (rt) is an anchor which is valid if it has a name, my
main problem is not being able to increment the ids/names. I could
see wanting to do this with divs in the future.
<form action="ts" method="post">
<table id="card">
<tr>
<td>
<Div id="rt">
access me
</Div>
</td>
<td>
<div class="clear_left label_vert float_left text">
<input name="day_task" type="text" class="clear_left float_left"
maxlength="45" size="30" />
</div>
</td>
</tr>
<tr>
<td>
<Div id="rt_1">
access me too
</Div>
</td>
<td>
<div class="text">
<input name="day_task_1" type="text" id="day_task_1" />
</div>
</td>
</tr>
<tr>
<td colspan="2">
<input name="num_lines" type="hidden" value="3" />
<div class="submit">
<input name="submit" type="submit" value="Save" />
</div>
</td>
</tr>
</table>
</form>
---
indicator: submit
action: ts
elements:
- type: Block
tag: table
id: card
elements:
- type: Block
tag: tr
elements:
- type: Block
tag: td
elements:
- type: Block
tag: Div
id: rt
content: "access me"
- type: Block
tag: td
elements:
- type: Text
name: day_task
render_processed_value: 1
container_attrs:
class: clear_left label_vert float_left
attributes:
size: 30
maxlength: 45
class: clear_left float_left
- type: Repeatable
tag: tr
name: timecard_rep
increment_field_names: 1
auto_id: %n
counter_name: num_lines
elements:
- type: Block
tag: td
elements:
- type: Block
tag: Div
id: rt
content: "access me too"
- type: Block
tag: td
elements:
- type: Text
name: day_task
- type: Block
tag: tr
elements:
- type: Block
tag: td
attributes:
colspan:2
elements:
- type: Hidden
name: num_lines
value: 3
retain_default: 1
- type: Submit
name: submit
value: Save
Stephen
More information about the HTML-FormFu
mailing list