function _form_model($bundle_name, $node = NULL) { $fields = get_fields($bundle_name); $models = array(); foreach ($fields as $name => $field) { switch ($field['type']) { case 'text': if (isset($node) && !empty($node->{$name})) { $count = count($node->{$name}['und']); } else { $count = 1; } $models[] = _text_field($name, $field['label'], $field['subtype'], $field['active'], true, $field['card'], 'width: 300px', $count); break; case 'text_long': case 'text_with_summary': if (isset($node) && !empty($node->{$name})) { $count = count($node->{$name}['und']); } else { $count = 1; } $models[] = _textarea_field($name, $field['label'], $field['active'], true, $field['card'], 'width: 300px; height: 90px', $count); break; case 'taxonomy_term_reference': $models[] = _taxonomy_field($name, $field['vocab'], $field['label'], $field['subtype'], $field['active'], true, $field['card']); break; default: break; } } return $models; }
function text_field($name, $value = null, $attributes = array()) { echo _text_field($name, $value, $attributes); }