Beispiel #1
0
 /**
  * Build the form element.
  */
 protected function build_form_element()
 {
     /* FIXME: Form id's should be unique, even if a form is rendered twice.
      * Perhaps a global cache of used form id's should be kept, and '-2'
      * suffixes added as needed? */
     assert('$this->_form instanceof AnewtForm; // Form renderer must have a AnewtForm instance');
     /* Default attributes */
     $id = $this->_form->_get('id');
     $attributes = array('method' => $this->_form->get('method-as-string'), 'action' => $this->_form->_get('action'), 'id' => $id);
     /* Encoding type */
     if ($this->_form->_contains_file_upload_control()) {
         $attributes['enctype'] = 'multipart/form-data';
     }
     /* Class name */
     if ($this->_form->_isset('class')) {
         $attributes['class'] = $this->_form->_get('class');
     }
     /* Output <form> element with all hidden elements */
     $form = new AnewtXHTMLForm(null, $attributes);
     /* The HTML DTD does not allow <input> elements as direct childs of
      * a <form> element. Use a <fieldset> that is completely hidden from
      * view instead. */
     $hidden_controls_fieldset = new AnewtXHTMLFieldset();
     $hidden_controls_fieldset->set_attribute('style', 'display: none;');
     foreach ($this->_form->_hidden_controls() as $hidden_control) {
         $hidden_controls_fieldset->append_child($hidden_control->build_widget());
     }
     $form->append_child($hidden_controls_fieldset);
     return $form;
 }
Beispiel #2
0
$ol = new AnewtXHTMLOrderedList(new AnewtXHTMLListItem('one'), new AnewtXHTMLListItem('two'), array('class' => 'foo'));
$ol->append_child(new AnewtXHTMLListItem('three', ' and last', array('class' => 'last')));
$fragment->append_child($ol);
$fragment->append_child(new AnewtXHTMLHeader3('Definition list'));
$fragment->append_child(new AnewtXHTMLDefinitionList(new AnewtXHTMLDefinitionTerm('foo'), new AnewtXHTMLDefinitionDescription('bar'), new AnewtXHTMLDefinitionTerm('quux'), new AnewtXHTMLDefinitionDescription('baz')), array('class' => 'definitions'));
/* Tables */
$fragment->append_child(new AnewtXHTMLHeader2('Tables'));
$table = new AnewtXHTMLTable();
$table_head = new AnewtXHTMLTableHead(new AnewtXHTMLTableRow(ax_fragment(new AnewtXHTMLTableHeaderCell('Column 1'), new AnewtXHTMLTableHeaderCell('Column 2'))));
$table->append_child($table_head);
$table_body = new AnewtXHTMLTableBody(ax_fragment(new AnewtXHTMLTableRow(ax_fragment(new AnewtXHTMLTableCell('r1c1'), new AnewtXHTMLTableCell('r1c2')), new AnewtXHTMLTableRow(ax_fragment(new AnewtXHTMLTableCell('r2c1'), new AnewtXHTMLTableCell('r2c2'))))));
$table->append_child($table_body);
$fragment->append_child($table);
/* Forms */
$fragment->append_child(new AnewtXHTMLHeader2('Forms'));
$form = new AnewtXHTMLForm(null, array('method' => 'GET'));
$input_fragment = new AnewtXHTMLFragment();
$input_fragment->append_child(new AnewtXHTMLLabel('Label: ', array('for' => 'test')));
$input_fragment->append_child(new AnewtXHTMLInput(null, array('name' => 'test', 'id' => 'test', 'type' => 'text')));
$form->append_child(new AnewtXHTMLParagraph($input_fragment));
$select = new AnewtXHTMLSelect(null, array('name' => 'select'));
$select->append_child(new AnewtXHTMLOption('First', array('value' => 'first')));
$select->append_child(new AnewtXHTMLOption('Second', array('value' => 'second')));
$select->append_child(new AnewtXHTMLOption('Third', array('value' => 'third')));
$form->append_child(new AnewtXHTMLParagraph($select));
$fragment->append_child($form);
$form->append_child(new AnewtXHTMLParagraph(new AnewtXHTMLInput(null, array('type' => 'submit'))));
/* Convenience API */
$r = array();
$r[] = ax_h2('Convenience API');
$r[] = ax_p('Test with some <& special characters.', array('style' => 'color: #ccc;'));