This is probably a general SS problem, but I'm finding this while doing forms :) I have a working custom form template which works nice. However, all the fields needs to be fitted in three <fieldset>'s instead of the original one.
I don't figure out how to do that. Using <% if First %>, Last, etc works fine, but not when I need to do this on specific positions.
I found some tips that the DataObject-view needs to be extended to be able to work around that, but how do I do that? My code looks something like this:
class MyForm extends Form {
function forTemplate() {
return $this->renderWith( array( $this->class, 'Form' ) );
}
}
class CashierPage_Controller extends Page_Controller {
function form() {
$fields = new FieldSet(
new TextField( 'Name', 'Your name' ),
new TextField( 'Country', 'Country' ),
new EmailField( 'Phone', 'Phone number' ),
new TextField( 'Email', 'Email' ),
new TextField( 'Location', 'Location where ticket was generated' )
);
$actions = new FieldSet(
new ResetFormAction( 'ClearAction', 'Cancel' ),
new FormAction( 'doFormSubmit', 'Send!' )
);
return new MyForm( $this, 'Form', $fields, $actions );
}
}
And template something like this:
<form $FormAttributes>
<% if Message %>
<p id="{$FormName}_error" class="message $MessageType">$Message</p>
<% else %>
<p id="{$FormName}_error" class="message $MessageType" style="display: none"></p>
<% end_if %>
<% control Fields %>
<% if First %>
<fieldset>
<legend>General information</legend>
<table border="0" cellpadding="0" cellspacing="0">
<% end_if %>
<tr>
<th><label for="$Id">$Title</label></th>
<td>$Field</td>
</tr>
<% if Last %>
</table>
</fieldset>
<% end_if %>
<% end_control %>
<% if Actions %>
<% control Actions %>$Field<% end_control %>
<% end_if %>
</form>