function form($objectName, $object, $options = array()) { if (!isset($options['action'])) { if ($object->isNewRecord()) { $options['action'] = 'create'; } else { $options['action'] = 'update'; } } if (!isset($options['submit_value'])) { $options['submit_value'] = ucfirst($options['action']); } if (isset($options['multipart']) && $options['multipart'] === true) { $form = form_tag(array('action' => $options['action']), array('multipart' => true)); } else { $form = form_tag(array('action' => $options['action'])); } if (!$object->isNewRecord()) { $form .= hidden_field($objectName, 'id', $object); } $fields = $object->contentAttributes(); foreach ($fields as $attr) { $form .= '<p><label for="' . $objectName . '_' . $attr->name . '">' . SInflection::humanize($attr->name) . "</label>\n" . input($objectName, $attr->name, $object) . "</p>\n"; } if (isset($options['include'])) { $form .= $options['include']; } $form .= submit_tag($options['submit_value']); $form .= end_form_tag(); return $form; }
function testHumanize() { $this->assertEqual('Post', SInflection::humanize('post_id')); $this->assertEqual('Relative post', SInflection::humanize('relative_post_id')); $this->assertEqual('My test', SInflection::humanize('my_test')); }
?> </p> <?php if (count($this->{$this->plural_name}) == 0) { ?> <p>No data.</p> <?php } else { ?> <table> <tr> <?php foreach ($attributes = $this->{$this->plural_name}[0]->contentAttributes() as $attr) { ?> <th><?php echo SInflection::humanize($attr->name); ?> </th> <?php } ?> </tr> <?php for ($i = 0; $i < ($count = count($this->{$this->plural_name})); $i++) { ?> <tr> <?php foreach ($attributes as $attr) { ?> <td><?php echo truncate($this->{$this->plural_name}[$i]->{$attr->name});