Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions administrator/components/com_content/Model/ArticleModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -708,12 +708,6 @@ public function getForm($data = array(), $loadData = true)
}
}

// Remove show_associations field if associations is not enabled
if (!$assoc)
{
$form->removeField('show_associations', 'attribs');
}

return $form;
}

Expand Down
26 changes: 20 additions & 6 deletions libraries/src/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,12 @@ public function filter($data, $group = null)
if ($input->exists($key))
{
$fieldObj = $this->loadField($field, $group);
$output->set($key, $fieldObj->filter($input->get($key, (string) $field['default']), $group, $input));

// Only set into the output if the field was supposed to render on the page (i.e. setup returned true)
if ($fieldObj)
{
$output->set($key, $fieldObj->filter($input->get($key, (string) $field['default']), $group, $input));
}
}
}

Expand Down Expand Up @@ -1199,13 +1204,22 @@ public function validate($data, $group = null)

$fieldObj = $this->loadField($field, $group);

$valid = $fieldObj->validate($input->get($key), $group, $input);
if ($fieldObj)
{
$valid = $fieldObj->validate($input->get($key), $group, $input);

// Check for an error.
if ($valid instanceof \Exception)
// Check for an error.
if ($valid instanceof \Exception)
{
$this->errors[] = $valid;
$return = false;
}
}
elseif (!$fieldObj && $input->exists($key))
{
$this->errors[] = $valid;
$return = false;
// The field returned false from setup and shouldn't be included in the page body - yet we received
// a value for it. This is probably some sort of injection attack and should be rejected
$this->errors[] = new \RuntimeException(Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', $key));
}
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/FormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ public function filter($value, $group = null, Registry $input = null)
* @param Registry $input An optional Registry object with the entire data set to validate
* against the entire form.
*
* @return boolean Boolean true if field value is valid, Exception on failure.
* @return boolean|\Exception Boolean true if field value is valid, Exception on failure.
*
* @since __DEPLOY_VERSION__
* @throws \InvalidArgumentException
Expand Down