";
// 2. label - could be common text label or drop down choice
// choose whether the label is a dropdown choice:
if (isset ( $param ['alt'] ) && is_array ( $param ['alt'] ) && sizeof ( $param ['alt'] > 0 )) {
$altList = array (
$key
) + $param ['alt'];
// Yii::info ( "altList : " . implode ( $altList, "\n" ) );
// echo " ";
echo Html::dropDownList ( $key, $key, $altList, $htmlOptions = array (
'class' => "dropDownLabel",
'id2' => $key
) );
$htmlOpts += array (
"class" => "hasSelectableLabel_" . $key,
"id2" => $key
);
$alt = true;
} else {
$altList = null;
$form->field ( $model, $key )->label ( $key );
$alt = false;
}
// 3. field itself (different types -depending on $type
self::createField ( $primaryObject, $model, $form, $key, $param, $selectionLists, $htmlOpts, $selectedValue = NULL, $label, $placeholder);
// if there are alternate fields create them and hide them:
if ($alt) {
if (isset ( $htmlOpts ['style'] )) {
$htmlOpts ['style'] += " display:none;";
} else {
$htmlOpts ['style'] = "display:none;";
}
foreach ( $altList as $altField ) {
unset ( $param ['valueList'] );
self::createField ( $primaryObject, $model, $form, $altField, $param, $selectionLists, $htmlOpts, $selectedValue = NULL, $label, $placeholder);
}
}
echo " ";
}
}
}
public static function prepareUpdateFormFields ($form, $model, $elements, $this, $filters, $cssClassSearchFields, $selectionLists, $label, $placeholder) {
echo $form->errorSummary ( $model );
echo "";
$suggestFields = [
'fullScientificName' ,
'sequenceaccessionIdentifier',
'country',
'continent',
'ocean',
'sea',
'geneticlocus',
'genusName',
'speciesName'
];
$defaultFields = [
'familyName',
'phylumName',
'className',
'orderName',
'unitID',
'ipen',
'locality',
'collectors',
'collectornumber' ,
'unitaccessionnumber',
'geneticlocus',
'preparationtype'
];
$selectFields = [
'kingdom',
'institution',
'voucherCol',
'sampletype',
'indexHerbarorium'
];
$buttonFields=['hasTypestatus', 'hasImage','sampleavailability', 'cites'];
$radioB=[];
foreach ( $elements as $key => $param ) {
if (isset ( $param ['type'] )) {
// echo "param config :".$param ['config'] ['name'].""; // 1. preparation for the field generation $type = $param ['type']; $selectedValue = ''; foreach ( $suggestFields as $tf ) if ($param ['config'] ['name'] == $tf && isset ( $filters [$tf] )) { $param ['config'] ['value'] = $filters [$tf]; $selectedValue = $filters [$tf]; $param ['type'] = 'suggest'; } foreach ( $defaultFields as $tf ) if ($param ['config'] ['name'] == $tf && isset ( $filters [$tf] )) { $param ['config'] ['value'] = $filters [$tf]; $selectedValue = $filters [$tf]; $param ['type'] = 'default'; } foreach ( $buttonFields as $tf ) if ($param ['config'] ['name'] == $tf && isset ( $filters [$tf] )) { $param ['config'] ['value'] = $filters [$tf]; $selectedValue = $filters [$tf]; $radioB[$tf] = $filters [$tf]; } if ($param ['config'] ['name'] == 'Multimedia' && isset ( $filters ['hasImage'] )) { $param ['config'] ['value'] = $filters ['hasImage']; $selectedValue = $filters ['accessionStatus']; $param ['type'] = 'checkbox'; } if ($param ['config'] ['name'] == 'Type status' && isset ( $filters ['hasTypestatus'] )) { $param ['config'] ['value'] = $filters ['hasTypestatus']; $selectedValue = $filters ['hasTypestatus']; $param ['type'] = 'checkbox'; } if ($param ['config'] ['name'] == 'Has reviewed identification' && isset ( $filters ['identifiedby'] )) { $param ['config'] ['value'] = $filters ['identifiedby']; $selectedValue = $filters ['identifiedby']; $param ['type'] = 'checkbox'; } if ($param ['config'] ['name'] == 'accStatus' && isset ( $filters ['accessionStatus'] )) { $param ['config'] ['value'] = $filters ['accessionStatus']; $selectedValue = $filters ['accessionStatus']; $param ['type'] = 'radio'; } if ($param ['config'] ['name'] == 'cites' && isset ( $filters ['cites'] )) { $param ['config'] ['value'] = $filters ['cites']; $selectedValue = $filters ['accessionStatus']; $param ['type'] = 'radio'; } if ($param ['config'] ['name'] == 'Coordinates' && (isset ( $filters ['latitudeFrom'] ) || isset ( $filters ['latitudeTo'] ) || isset ( $filters ['longitudeTo'] ) || isset ( $filters ['longitudeFrom'] ))) { handleCoordinates ( $filters,$key,$param, $selectionLists, $this, $model, $form, $selectedValue); } if ($param ['config'] ['name'] == 'Collection Year' && (isset ( $filters ['collectionYearFrom'] ) || isset ( $filters ['collectionYearTo'] ))) { handleGatheringyear ( $filters,$key,$param, $selectionLists, $this, $model, $form, $selectedValue ); } foreach ( $selectFields as $tf ) if ($param ['config'] ['name'] == $tf && isset ( $filters [$tf] )) { $selectedValue = $filters [$tf]; $param ['type'] = 'select'; $param ['config'] ['value'] = $filters [$tf]; } $htmlOpts = isset ( $param ['config'] ) ? $param ['config'] : []; // Rukeia 30-03-2015: If the field was not used for the search, it's set not to be displayed in the // first place and it gets a button to hide it again: if (! isset ( $param ['config'] ['value'] ) && $selectedValue == '') { // Rukeia 30-03-2015: added $hide_option = "style=\"display:none;\""; $hide_button = "request->baseUrl . "/images/close.png \" parent_name=\"" . $key . "\" class=\"hide_button\" alt=\"close\"/>"; } else { $hide_option = ""; $hide_button = "request->baseUrl . "/images/close.png \" parent_name=\"" . $key . "\" class=\"hide_button\" alt=\"close\"/>"; } // use default size if no size is given if (! isset ( $param ['config'] ['size'] )) { $param ['config'] ['size'] = $model->getFieldSize (); } // surround label and fields with div echo " ";
// 2. label - could be common text label or drop down choice
// choose whether the label is a dropdown choice:
if (isset ( $param ['alt'] ) && is_array ( $param ['alt'] ) && sizeof ( $param ['alt'] > 0 )) {
$altList = array (
$key
) + $param ['alt'];
echo Html::dropDownList ( $key, $key, $altList, $htmlOptions = array (
'class' => "dropDownLabel",
'id2' => $key
) );
$htmlOpts += array (
"class" => "hasSelectableLabel_" . $key,
"id2" => $key
);
$alt = true;
} else {
$altList = null;
// echo $form->labelEx ( $model, $key );
$form->field ( $model, $key )->label ( $key );
$alt = false;
}
echo $hide_button;
// 3. field itself (different types -depending on $type
self::createField ( $this, $model, $form, $key, $param, $selectionLists, $htmlOpts, $selectedValue, $label, $placeholder);
// if there are alternate fields create them and hide them:
if ($alt) {
if (isset ( $htmlOpts ['style'] )) {
$htmlOpts ['style'] += " display:none;";
} else {
$htmlOpts ['style'] = "display:none;";
}
foreach ( $altList as $altField ) {
unset ( $param ['valueList'] );
self::createField ( $this, $model, $form, $altField, $param, $selectionLists, $htmlOpts, $selectedValue, $label, $placeholder );
}
}
echo " ";
}
}
}
public static function AddAccordion ($headerTitle, $headerClass, $itemContent) {
echo Accordion::widget ( [
'items' => [
[
'header' => $headerTitle,
'content' => $itemContent
]
],
'options' => [
'tag' => 'div',
'autoHeight' => false,
'active' => false,
'delay' => '100'
],
'itemOptions' => [
'tag' => 'div',
'class' => 'balmusette_search'
],
'headerOptions' => [
'tag' => 'button',
'class' => $headerClass
],
'clientOptions' => [
'collapsible' => true,
'active' => false
]
] );
}
}
?> |