Jump to content
Sign in to follow this  
fliwire

InputfieldSelect::processInput disable validation

Recommended Posts

how to disable validation with processInput hook? Or maybe better solved this problem?
Tried to load custom options and save value.
 

$wire->addHookBefore('InputfieldSelect::render', function (HookEvent $event) {
	$InputfieldSelect = $event->object;

	if ($InputfieldSelect->name == "dselect") {
		$page = wire("page");
		$event->replace = true;

		$options = [
			"1" => "test2",
			"2" => "test3",
			"3" => "test4",
		];

		$attrs = $InputfieldSelect->getAttributes();
		unset($attrs['value']);

		foreach ($options as $key => $value) {
			$selected = $key == $page->dselect ? "selected" : "";
			$out .= "<option value='{$key}' $selected>{$value}</option>";
		}

		$out = "<select " . $InputfieldSelect->getAttributesString($attrs) . ">{$out}</select>";

		$event->return = $out;
	}
});

// tried for disable validation
$wire->addHookBefore('InputfieldSelect::processInput', function (HookEvent $event) {
	$field = $event->object;

	if ($field->attr('name') == "dselect") {
		$page = wire("page");
		$event->replace = true;

		// $field->setAttribute('value', input("post", "dselect"));
		$event->arguments(0, $field);
	}
});



 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...