Skip to content

Instantly share code, notes, and snippets.

@Septdir
Last active October 11, 2019 11:15
Show Gist options
  • Save Septdir/261f2934597c34c3f7b778f2f6aa675a to your computer and use it in GitHub Desktop.
Save Septdir/261f2934597c34c3f7b778f2f6aa675a to your computer and use it in GitHub Desktop.
Set uikit classes to joomla form
<?php
// Set uikit form
foreach ($this->form->getFieldsets() as $key => $fieldset)
{
foreach ($this->form->getFieldset($key) as $field)
{
$name = $field->fieldname;
$group = $field->group;
$type = strtolower($field->type);
$class = $this->form->getFieldAttribute($name, 'class', '', $group);
$input = $field->input;
if ($type === 'text')
{
$class .= 'uk-input';
}
if ($type === 'list' || preg_match('#<select#', $input))
{
$class .= 'uk-select';
}
elseif ($type === 'textarea' || preg_match('#<textarea#', $input))
{
$class .= 'uk-textarea';
}
elseif ($type === 'range')
{
$class .= 'uk-range';
}
$this->form->setFieldAttribute($name, 'class', $class, $group);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment