Created
June 6, 2012 13:58
-
-
Save erochest/2882011 to your computer and use it in GitHub Desktop.
Snippet to refactor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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