Last active
October 11, 2019 11:15
-
-
Save Septdir/261f2934597c34c3f7b778f2f6aa675a to your computer and use it in GitHub Desktop.
Set uikit classes to joomla form
This file contains 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
<?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