Skip to content

Instantly share code, notes, and snippets.

@erochest
Created June 6, 2012 13:58
Show Gist options
  • Save erochest/2882011 to your computer and use it in GitHub Desktop.
Save erochest/2882011 to your computer and use it in GitHub Desktop.
Snippet to refactor
public static function createFacetSubForm($subform)
{
$output = '';
$facetId = $subform->getElement('facetid');
$label = $subform->getElement('label');
$options = $subform->getElement('options');
$id = preg_replace('/\W+/', '_', $label->getFullyQualifiedName());
$output .= '<tr>';
$output .= '<td class="element">';
$output .= "<input name='{$facetId->getFullyQualifiedName()}' type='hidden' value='{$facetId->getValue()}' />";
$output .= "<div id='{$id}' class='facetlabel'>{$label->getValue()}</div>";
$output .= '<script type="text/javascript">';
$output .= "jQuery(function() { jQuery('#{$id}')";
$output .= ".textinplace({revert_to: '{$label->getAttrib('revertto')}', ";
$output .= "form_name: '{$label->getFullyQualifiedName()}'}); });";
$output .= '</script>';
$output .= '</td>';
foreach ($options->getMultiOptions() as $name => $label) {
$output .= '<td>';
$output .= "<input type='checkbox' name='{$options->getFullyQualifiedName()}' value='$name' ";
if (in_array($name, $options->getValue())) {
$output .= ' checked="checked"';
}
$output .= '/>';
$output .= '</td>';
}
$output .= '</tr>';
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment