10 defined(
'JPATH_PLATFORM') or die;
28 protected $type =
'Repeatable';
37 protected function getInput()
40 $subForm =
new JForm($this->name, array(
'control' =>
'jform'));
41 $xml = $this->element->children()->asXML();
45 $subForm->repeatCounter = (int) @$this->form->repeatCounter;
46 $children = $this->element->children();
48 $subForm->setFields($children);
50 $modalid = $this->
id .
'_modal';
53 $str[] =
'<div id="' . $modalid .
'" style="display:none">';
54 $str[] =
'<table id="' . $modalid .
'_table" class="adminlist ' . $this->element[
'class'] .
' table table-striped">';
55 $str[] =
'<thead><tr>';
57 $attributes = $this->element->attributes();
59 foreach ($subForm->getFieldset($attributes->name .
'_modal') as $field)
61 $names[] = (string) $field->element->attributes()->name;
62 $str[] =
'<th>' . strip_tags($field->getLabel($field->name));
63 $str[] =
'<br /><small style="font-weight:normal">' .
JText::_($field->description) .
'</small>';
67 $str[] =
'<th><a href="#" class="add btn button btn-success"><span class="icon-plus"></span> </a></th>';
68 $str[] =
'</tr></thead>';
69 $str[] =
'<tbody><tr>';
71 foreach ($subForm->getFieldset($attributes->name .
'_modal') as $field)
73 $str[] =
'<td>' . $field->getInput() .
'</td>';
77 $str[] =
'<div class="btn-group"><a class="add btn button btn-success"><span class="icon-plus"></span> </a>';
78 $str[] =
'<a class="remove btn button btn-danger"><span class="icon-minus"></span> </a></div>';
80 $str[] =
'</tr></tbody>';
84 $names = json_encode($names);
86 JHtml::_(
'script',
'system/repeatable.js',
true,
true);
89 $maximum = $this->element[
'maximum'] ? (int) $this->element[
'maximum'] :
'999';
91 $script =
"(function ($){
92 $(document).ready(function (){
93 var repeatable = new $.JRepeatable('$modalid', $names, '$this->id', '$maximum');
98 $document->addScriptDeclaration($script);
100 $select = (string) $this->element[
'select'] ?
JText::_((
string) $this->element[
'select']) :
JText::_(
'JLIB_FORM_BUTTON_SELECT');
101 $icon = $this->element[
'icon'] ?
'<i class="icon-' . $this->element[
'icon'] .
'"></i> ' :
'';
102 $str[] =
'<button class="btn" id="' . $modalid .
'_button" data-modal="' . $modalid .
'">' . $icon . $select .
'</button>';
104 if (is_array($this->value))
106 $this->value = array_shift($this->value);
109 $value = htmlspecialchars($this->value, ENT_COMPAT,
'UTF-8');
110 $str[] =
'<input type="hidden" name="' . $this->name .
'" id="' . $this->
id .
'" value="' . $value .
'" />';
114 return implode(
"\n", $str);