$w->addFormFormatter('custom', new WidgetSchemaFormatterList($w)); $t->is($f->renderUsing('custom'), fix_linebreaks($output), 'renderUsing() renders a custom form formatter'); try { $f->renderUsing('nonexistant'); $t->fail('renderUsing() throws an exception if formatter name does not exist'); } catch (\InvalidArgumentException $e) { $t->pass('renderUsing() throws an exception if formatter name does not exist'); } catch (\Exception $e) { $t->pass('renderUsing() throws an exception if formatter name does not exist'); } // renderHiddenFields() $t->diag('->renderHiddenFields()'); $f = new Form(); $f->setWidgets(array('id' => new WidgetInputHidden(), 'name' => new WidgetInputText(), 'is_admin' => new WidgetInputHidden())); $output = '<input type="hidden" name="id" id="id" /><input type="hidden" name="is_admin" id="is_admin" />'; $t->is($f->renderHiddenFields(), $output, 'renderHiddenFields() renders all hidden fields, no visible fields'); $t->is(count($f->getFormFieldSchema()), 3, 'renderHiddenFields() does not modify the form fields'); $author = new Form(); $author->setWidgets(array('id' => new WidgetInputHidden(), 'name' => new WidgetInputText())); $company = new Form(); $company->setWidgets(array('id' => new WidgetInputHidden(), 'name' => new WidgetInputText())); $author->embedForm('company', $company); $output = '<input type="hidden" name="id" id="id" /><input type="hidden" name="company[id]" id="company_id" />'; $t->is($author->renderHiddenFields(), $output, 'renderHiddenFields() renders hidden fields from embedded forms'); $output = '<input type="hidden" name="id" id="id" />'; $t->is($author->renderHiddenFields(false), $output, 'renderHiddenFields() does not render hidden fields from embedded forms if the first parameter is "false"'); // ->embedForm() $t->diag('->embedForm()'); $author = new FormTest(array('first_name' => 'Fabien')); $author->setWidgetSchema($author_widget_schema = new WidgetSchema(array('first_name' => new WidgetInputText()))); $author->setValidatorSchema($author_validator_schema = new ValidatorSchema(array('first_name' => new ValidatorString(array('min_length' => 2)))));