'repeater',
'type' => 'repeater',
'layout' => 'table',
'add_row_text' => null,
'min_rows' => 1,
'max_rows' => 999,
'sorting' => true,
'controls' => array(),
'default_value' => array()
);
public function RsRepeater(){
$this->addControl('repeater', 'repeater');
}
public function loadFiles(){
rs::loadStyle('rs-repeater', RS_LIB_URL . '/controls/repeater/repeater.min.css');
rs::loadScript('jquery-ui-sortable');
rs::loadScript('rs-repeater', RS_LIB_URL . '/controls/repeater/repeater.min.js', true);
}
public function render($options = array()){
if(!$options = $this->parseOptions($options)){
return $this->renderError();
}
$this->loadFiles();
$wrapid = $this->addConditionalLogic($options);
if(!is_array($options['controls'])){
return rs::message('Controls must be an array.', 'Repeater ' . $options['name']);
}
$options['add_row_text'] = $options['add_row_text'] !== null ? $options['add_row_text'] : ($options['layout'] == 'single' ? 'Add Item' : 'Add Row');
if(!is_array($options['value'])){
$options['value'] = array();
}
foreach($options['value'] as $index=>$value){
if(!is_numeric($index)){
unset($options['value'][$index]);
}
}
$options['value'] = array_values($options['value']);
foreach($options['controls'] as $key => $control){
if(is_array($control)){
if(empty($control['name']) && $control['type'] != 'group'){
$control['name'] = $control['type'];
}
if(empty($control['label'])){
$control['label'] = ucfirst($control['name']);
}
if(empty($control['description'])){
$control['description'] = '';
}
$options['controls'][$key] = $control;
}
else{
unset($options['controls'][$key]);
}
}
$options['sorting'] = $options['sorting'] ? 'sorting-true' : 'sorting-false';
?>
renderSingleLayout($options);
}
else if($options['layout'] == 'row'){
$this->renderRowLayout($options);
}
else{
$this->renderTableLayout($options);
}
?>
renderError($return['message']);
}
}
function renderSingleLayout($options){
$control = $options['controls'][0];
?>
$value) { ?>
|
renderControl($control);
if($control['description']){
?>
|
+
-
|
|
renderControl($control);
if($control['description']){
?>
|
+
-
|
|
renderControl($control);
if($control['description']){
?>
|
+
-
|
|
$control) {
$style = $key != $last_key ? 'width:'.(90/$length).'%' : '';
?>
|
|
$value) { ?>
|
$control) {?>
renderControl($control);
if($control['description']){
?>
|
+
-
|
|
renderControl($control);
if($control['description']){
?>
|
+
-
|
|
renderControl($control);
if($control['description']){
?>
|
+
-
|
$value) { ?>
|
$control) :
unset($control['value']);
if(isset($options['value'][$i][$control['name']])){
$control['value'] = $value[$control['name']];;
}
$control['name'] = $options['field_name'].'['.$i.']['.$control['name'].']';
if(isset($control['field_id'])){
$control['conditional_logic_id'] = rs::generateId($control['field_id']) . '-field';
}
else{
$control['conditional_logic_id'] = rs::generateId($control['name']) . '-field';
}
?>
|
|
renderControl($control);
?>
|
|
+
-
|
|
|
|
renderControl($control);
?>
|
|
+
-
|
|
|
|
renderControl($control);
?>
|
|
+
-
|