/** * Returns whether or not the given Inputfield should be processed by processInput() * * When an $inputfield has a 'showIf' property, then this returns false, but it queues * the field in the delayedChildren array for later processing. The root container should * temporarily remove the 'showIf' property of inputfields they want processed. * * @param Inputfield $inputfield * @return bool * */ public function isProcessable(Inputfield $inputfield) { if (!$inputfield->editable()) { return false; } // visibility settings that aren't saveable static $skipTypes = array(Inputfield::collapsedHidden, Inputfield::collapsedLocked, Inputfield::collapsedNoLocked, Inputfield::collapsedYesLocked); $collapsed = (int) $inputfield->getSetting('collapsed'); if (in_array($collapsed, $skipTypes)) { return false; } if (in_array($collapsed, array(Inputfield::collapsedYesAjax, Inputfield::collapsedBlankAjax))) { $processAjax = $this->wire('input')->post('processInputfieldAjax'); if (is_array($processAjax) && in_array($inputfield->attr('id'), $processAjax)) { // field can be processed (convention used by InputfieldWrapper) } else { if ($collapsed == Inputfield::collapsedBlankAjax && !$inputfield->isEmpty()) { // field can be processed because it is only collapsed if blank } else { if (isset($_SERVER['HTTP_X_FIELDNAME']) && $_SERVER['HTTP_X_FIELDNAME'] == $inputfield->attr('name')) { // field can be processed (convention used by ajax uploaded file and other ajax types) } else { // field was not rendered via ajax and thus can't be processed return false; } } } } // if dependencies aren't in use, we can skip the rest if ($this->useDependencies === false) { return true; } if (strlen($inputfield->getSetting('showIf')) || $inputfield->getSetting('required') && strlen($inputfield->getSetting('requiredIf'))) { $name = $inputfield->attr('name'); if (!$name) { $name = $inputfield->attr('id'); if (!$name) { $name = $this->wire('sanitizer')->fieldName($inputfield->label); } $inputfield->attr('name', $name); } $this->delayedChildren[$name] = $inputfield; return false; } return true; }