logo
down
shadow

always get The input was not found in the haystack in zf2 select element


always get The input was not found in the haystack in zf2 select element

By : Finix Shuphalax
Date : November 18 2020, 11:13 AM
will help you I am new in zf2 , oho God,
I got the solution
code :
    $language = new Element\Select('language');
    $language->setAttributes(array(
            'id' => 'language',
            'class' => 'form-control',
        ));
    $language->setDisableInArrayValidator(true);
    $this->add($language);
    $language = new InputFilter\Input(‘language’);
    $language->setRequired(false);
     $language->setErrorMessage(‘Please select language’);
   $inputFilter->add($language);


Share : facebook icon twitter icon
Insert string into 'haystack' whenever 'needle' is found and put the haystack back together

Insert string into 'haystack' whenever 'needle' is found and put the haystack back together


By : Cherub
Date : March 29 2020, 07:55 AM
wish of those help , Maybe use str_replace?
code :
str_replace("%name%", $name, $rhyme);
Capybara::Element Not Found for <select> populated by onchange of previous element

Capybara::Element Not Found for <select> populated by onchange of previous element


By : Simon Marshall
Date : March 29 2020, 07:55 AM
this one helps. All that was required was to enable Javascript via adding the :js => true flag when the scenario was defined, like so:
code :
scenario 'happy path that uses AJAX', :js=>true do
   #etc.
end
how to select all data whose input array found and not found in mysql

how to select all data whose input array found and not found in mysql


By : milkyfox
Date : March 29 2020, 07:55 AM
like below fixes the issue A helper table is used for the left join / right join concept but it was not quite as simple.
From my answer here (Edit3) Here:
code :
CREATE TABLE 4kTable
(   -- a helper table of about 4k consecutive ints
    id int auto_increment primary key,
    thing int null
)engine=MyISAM;

insert 4kTable (thing) values (null),(null),(null),(null),(null),(null),(null),(null),(null);
insert 4kTable (thing) select thing from 4kTable;
insert 4kTable (thing) select thing from 4kTable;
insert 4kTable (thing) select thing from 4kTable;
insert 4kTable (thing) select thing from 4kTable;
insert 4kTable (thing) select thing from 4kTable;
insert 4kTable (thing) select thing from 4kTable;
insert 4kTable (thing) select thing from 4kTable;
insert 4kTable (thing) select thing from 4kTable;
insert 4kTable (thing) select thing from 4kTable;
-- verify:
-- select min(id),max(id),count(*) from 4kTable;
-- 1 4608 4608

ALTER TABLE 4kTable ENGINE = InnoDB; -- *********** it is now InnoDB
select SUBSTRING_INDEX(SUBSTRING_INDEX(@str, ',', 4k.id), ',', -1) name 
from 
  4kTable 4k  
  cross join (select @str:='SMITH,WARD,KING,TOM') vars 
  on CHAR_LENGTH(@str) 
     -CHAR_LENGTH(REPLACE(@str, ',', ''))>=4k.id-1; 
+-------+
| name  |
+-------+
| SMITH |
| WARD  |
| KING  |
| TOM   |
+-------+
select d.name as rtable_name,e.empno,e.ename,e.job,e.mgr,e.hiredate,e.sal,e.comm,e.deptno 
from emp e 
right join 
(   select SUBSTRING_INDEX(SUBSTRING_INDEX(@str, ',', 4k.id), ',', -1) name  
    from 4kTable 4k  
    cross join (select @str:='SMITH,WARD,KING,TOM') vars 
    on CHAR_LENGTH(@str) 
        -CHAR_LENGTH(REPLACE(@str, ',', ''))>=4k.id-1 
) d 
on d.name=e.ename; 
+-------------+-------+-------+-----------+------+------------+---------+--------+--------+
| rtable_name | empno | ename | job       | mgr  | hiredate   | sal     | comm   | deptno |
+-------------+-------+-------+-----------+------+------------+---------+--------+--------+
| SMITH       |  7369 | SMITH | CLERK     | 7902 | 1980-12-17 |  800.00 |   NULL |     20 |
| WARD        |  7521 | WARD  | SALESMAN  | 7698 | 1981-02-22 | 1250.00 | 500.00 |     30 |
| KING        |  7839 | KING  | PRESIDENT | NULL | 1981-11-17 | 5000.00 |   NULL |     10 |
| TOM         |  NULL | NULL  | NULL      | NULL | NULL       |    NULL |   NULL |   NULL |
+-------------+-------+-------+-----------+------+------------+---------+--------+--------+
Radio button: input was not found in the haystack?

Radio button: input was not found in the haystack?


By : Mantiri Ade Putra
Date : March 29 2020, 07:55 AM
help you fix your problem The problem lies with when you use the setValueOptions() and the setDisableInArrayValidator(). You should do this earlier within your code as it is never set before validating your form and so the inputfilter still contain the defaults as the InArray validator. As after validation, which checks the inputfilter, you set different options for the shipping_methods.
You should move the setValueOptions() and the setDisableInArrayValidator() before the $form->isValid(). Either by setting the right options within the form itsself or doing this in the controller. Best way is to keep all of the options in one place and doing it inside the form class.
code :
$this->add([
    'name' => 'shipping-method',
    'type' => 'Zend\Form\Element\Radio',
    'options' => [
        'value_options' => [
            'Ground'    => 'Ground',
            'Expedited' => 'Expedited'
        ],
        'disable_inarray_validator' => true,
        'label' => 'Shipping Method',
        'label_attributes' => [
            'class' => 'lbl-shipping-method',
        ],
    ],
]);
class ShippingForm extends Form
{
    private $dbAdapter;

    public function __construct(AdapterInterface $dbAdapter, $name = 'shipping-form', $options = [])
    {
        parent::__construct($name, $options)
        // inject the databaseAdapter into your form
        $this->dbAdapter = $dbAdapter;
    }

    public function init()
    {
        // adding form elements to the form
        // we use the init method to add form elements as from this point
        // we also have access to custom form elements which the constructor doesn't

        $this->add([
            'name' => 'shipping-method',
            'type' => 'Zend\Form\Element\Radio',
            'options' => [
                'value_options' => $this->getDbValueOptions(),
                'disable_inarray_validator' => true,
                'label' => 'Shipping Method',
                'label_attributes' => [
                    'class' => 'lbl-shipping-method',
                ],
            ],
        ]);
    }

    private function getDbValueOptions()
    {
        $statement = $this->dbAdapter->query('SELECT shipping_method FROM shipping');
        $rows = $statement->execute();

        $valueOptions = [];

        foreach ($rows as $row) {
            $valueOptions[$row['shipping_method']] = $row['shipping_method'];
        }

        return $valueOptions;
    }
}
How to fix 'The input was not found in the haystack' in ZF2?

How to fix 'The input was not found in the haystack' in ZF2?


By : user3425251
Date : March 29 2020, 07:55 AM
Does that help Of course it's not working.
That message comes from the \Zend\Validator\InArray and essentially, it means: "your user is doing something hacky with your select, pay attention".
code :
$this->add(array(
    'name' => 'ACTIVITE1',
    'type' => 'Zend\Form\Element\Select',
    'required' => 'required',
    'options' => array(
        'value_options' => array(
            1 => 'Fitness',
            2 => 'Parcour',
            3 => 'Velo',
            4 => 'Tapis roulant',
            // ... and so on
        )
    ),
    'attributes' => array(
        'class' => 'form-control',
        'id' => 'select-session1',
        'placeholder' => "Choisir l'activité"
    )
));
namespace Yournamespace;

use Zend\Form\Element\Select;
use Yournamespace\ActivityMapper;

class ActivitySelect extends Select {

    protected $activityMapper;

    public function __construct(ActivityMapper $activityMapper, $name = null, $options = []) {
        parent::__construct($name, $options);
        $this->activityMapper = $activityMapper;
    }

    public function init() {
        $valueOptions = [];
        foreach ($this->activityMapper->fetchAll() as $activity) {
            $valueOptions[$activity->getActivityId()] = $activity->getActivityName();
        }
        $this->setValueOptions($valueOptions);
    }

}
namespace Yournamespace;

use Zend\ServiceManager\Factory\FactoryInterface;
use \Interop\Container\ContainerInterface;

class ActivitySelectFactory implements FactoryInterface {

    public function __invoke(ContainerInterface $container, $requestedName, array $options = null): object {
        $activityMapper = $container->get(\Yournamespace\ActivityMapper::class);
        return \Yournamespace\ActivitySelect($activityMapper);
    }

}
return [
    // ...
    'form_elements' => [
        'factories' => [
            \Yournamespace\ActivitySelect::class => \Yournamespace\ActivitySelectFactory::class,
        ]
    ]
    // ...
];
namespace Yournamespace;

use Zend\Form\Form;
use Zend\InputFilter\InputFilterProviderInterface;

class ActivityForm extends Form implements InputFilterProviderInterface {

    public function init() {
        parent::init();

        // ...
        $this->add([
            'name' => 'ACTIVITE1',
            'type' => \Yournamespace\ActivitySelect::class,
            'attributes' => [
                'class' => 'form-control',
                'id' => 'select-session1',
                'required' => true, // This will work only clientside, don't forget the inputfilter!
                'placeholder' => 'Choisir l\'activité',
            ],
            'options' => [
                'label' => 'Choisir l\'activité',
            ]
        ]);
        // ...

    }

    public function getInputFilterSpecification() {
        // ...
        $inputFilter[] = [
            'name' => 'ACTIVITE1',
            'required' => true
        ];
        // ...
        return $inputFilter;
    }

}
namespace Yournamespace;

use Zend\Form\FormElementManager;

class YourController extends AbstractActionController {
    private $formManager;

    public function __construct(FormElementManager $formManager) {
        $this->formManager = $formManager;
    }

    public function choisirActiviteAction(){
        // ...
        $form = $this->formManager->get(\Yournamespace\ActivityForm::class);
        // ...
    }
}
Related Posts Related Posts :
  • how to run wordpress php snippet mysql update command from ssh and/ultimately cron
  • how to get xml tag by name
  • ModSecurity maximum post limits (PCRE limit errors)
  • Call controller/action in event listener
  • How to improve performance of contacting WebService?
  • PHP nest variable in echoed string that contains a HTML tag in the end
  • Multiple Ajax request for PHP framework
  • Debug Info from Moodle Plugin
  • passing variables through page
  • Passing PHP $result data to Javascript
  • cakePHP File Download was not found or not readable
  • batch waiting until script finishes
  • PHP variables and anchors in URL
  • php eTag generation using php
  • How to check whether the array is an Integer or Not?
  • Is it possible to install Doctrine without PEAR or Composer? If so, how?
  • Call view script of (parent) Abstract controller Zend
  • Curl PHP cannot display amazon
  • Symfony, getters and setters vs magic methods
  • Using 'continue' PHP instruction outside the loop
  • AJAX POST return data not appearing
  • Can I query relations using an INNER JOIN instead of two queries in Eloquent?
  • Looping through dynamic form fields and inserting into database
  • My php code can't select mysql auto_increment value
  • Store Angularjs form data in database using php
  • I want to run my sh file continuously even if I close my Putty connection
  • file_get_contents equivalent for gzipped files
  • Include PHP file with jQuery
  • php curl headers do not return from website?
  • How to find out, if facebook ID is a user, group or page
  • Connect webhost database to android database
  • preg_match get div content with class
  • Upload multiple files in Laravel 4
  • Count array numbers in multidimensional array
  • PHP Date diff with a difference
  • Search Customer by custom field in Netsuite
  • Is it possible to hide/encode/encrypt php source code and let others have the system?
  • list items to be displayed using php code and array
  • check if row exists mysqli
  • PHP errors loading MySQL
  • setup PostgreSQL with Laravel in MAMP
  • PHP - CodeIgniter Notifications
  • Encrypting a password column in a SQL database
  • New to PHP, trying to extract information from another website
  • JavaScript AmChart to Image for Email
  • Is javascript validation enough to keep my forms secure?
  • Regex extract variables from [shortcode]
  • Download a .mp3 link and save it to computer with PHP
  • Error with the ereg_replace
  • Getting the fields attached to a bundle of an entity in Drupal
  • Php how to check multiple times (within `foreach`) if values from array exists in mysql?
  • MySQL and PHP parsing strange string
  • Pull specific data from multidimensional associative array
  • How to get the original URI extension using PHP Tonic?
  • Upload videos and images from Android to PHP server?
  • Unset a multidimensional array with another multidimensional array with values than key
  • Calling a user e-mail to add to a mailto link PHP
  • Why is override_function coming back as an undefined function
  • PHP mySQLi_fetch_all: iterate through each row
  • Using pow in php
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org