/** * Converts a mardown string into HTML * * sfWidgetFormTextarea * sfWidgetFormInput * sfWidgetFormInputCheckbox * * @package Reditype * @subpackage helper * @author Piers Warmers <*****@*****.**> * @param sfFormField $widget * @param array $options * @return string */ function render_form_row(sfFormField $widget, $options = array()) { $options['wide'] = isset($options['wide']) ? $options['wide'] : true; $options['space'] = isset($options['space']) ? $options['wide'] : false; $options['class'] = isset($options['class']) ? $options['class'] : 'rt-form-row'; $options['markdown'] = isset($options['markdown']) ? $options['markdown'] : false; $content = ''; if ($options['markdown']) { ob_start(); include_partial('rtSearch/ajaxForm', array('form' => new rtSearchForm(), 'targetId' => 'rt_wiki_page_en_content')); $content = ob_get_contents(); ob_end_clean(); } $html = ''; $widget->renderHelp(); $help = $widget->getParent()->getWidget()->getHelp($widget->getName()); if (get_class($widget->getWidget()) === 'sfWidgetFormInputCheckbox') { $html = sprintf('<tr class="%1$s checkbox"><th><label for="%6$s">%2$s</label></th><td>%4$s <div class="help">%5$s</div> %3$s</td></tr>', $options['class'], $widget->renderLabelName(), $widget->hasError() ? $widget->renderError() : '', $widget->render(), $help, $widget->renderId()); } elseif (in_array(get_class($widget->getWidget()), array('sfWidgetFormChoice', 'sfWidgetFormDate', 'sfWidgetFormDateTime'))) { $html = sprintf('<tr class="%1$s checkbox"><th><label>%2$s</label></th><td>%4$s <div class="help">%5$s</div> %3$s</td></tr>', $options['class'], $widget->renderLabelName(), $widget->hasError() ? $widget->renderError() : '', $widget->render(), $help); } else { $html = sprintf('<tr class="%1$s standard"><th><label for="%2$s">%3$s</label></th><td>%4$s %5$s <div class="help">%6$s</div>%7$s</tr>', $options['class'], $widget->renderId(), $widget->renderLabelName(), $widget->hasError() ? '<span class="error">' . $widget->renderError() . '</span>' : '', $widget->render(), $help, $content); } return $html . "\n"; }
function outputFormField(sfFormField $field, $subtext = null, $attrib = array()) { $errClass = array('class' => 'input-error'); $curErr = $field->hasError() ? $errClass : array(); $attributes = array_merge($attrib, $curErr); if ($field->getWidget() instanceof sfWidgetFormInputCheckbox) { $attributes['class'] = isset($attributes['class']) ? $attributes['class'] . ' checkbox' : 'checkbox'; } $output = $field->render($attributes); $output .= $field->hasError() ? '<span class="error-msg">' . $field->getError() . '</span>' : ''; $help_text = $subtext ? $subtext : $field->renderHelp(); $output .= $help_text ? '<span class="input_label">' . $help_text . '</span>' : ''; return $output; }