मेरे पास 0 फ़ील्ड, राशि और मुद्रा के साथ धन फ़ील्डसेट है।बदलें फ़ील्डसेट फ़ील्ड 'आवश्यक पैरामीटर गतिशील रूप से
class MoneyFieldset ...
{
public function __construct($name = null, $options = array())
{
parent::__construct($name, $options);
$this->setHydrator(...);
$this->add(array(
'name' => 'currency',
'type' => 'select',
'options' => array(
'value_options' => \Core\Service\Money::getAvailableCurrencies(true),
),
'attributes' => array(
'value' => \Core\Service\Money::DEFAULT_CURRENCY,
),
));
$this->add(array(
'name' => 'amount',
'type' => 'text',
));
}
}
public function getInputFilterSpecification()
{
$default = [
'amount' => [
'required' => false,
'allow_empty' => true,
'filters' => [
['name' => AmountFilter::class]
],
'validators' => [
]
],
'currency' => [
'required' => false,
'allow_empty' => true,
'filters' => [
['name' => StringToUpper::class]
],
'validators' => [
]
]
];
return \Zend\Stdlib\ArrayUtils::merge($default, $this->filterSpec, true);
}
मैं moneyFieldset उपयोग कर रहा हूँ मेरे अन्य fieldsets में इस तरह:
// Price Field
$this->add(array(
'name' => 'price',
'type' => 'form.fieldset.moneyFieldset',
'attributes' => array(
'required' => true,
'invalidText' => 'Please type an amount'
),
'options' => array(
...
),
));
जब मैं इस तरह फ़िल्टर सेट:
function getInputFilterSpecification()
{
'price' => [
'required' => true,
'allow_empty' => false,
],
}
यह काम नहीं कर रहा है क्योंकि कीमत है 2 फ़ील्ड, तो मैं कैसे कह सकता हूं मूल्य [राशि] और कीमत [curreny] आवश्यक है?
मैंने कोशिश की है लेकिन कुछ भी नहीं बदला है। यह आउटपुट है: '<इनपुट प्रकार =" टेक्स्ट "नाम =" सूची [मूल्य] [राशि] "वर्ग =" फॉर्म-कंट्रोल "मान =" ">>'। कोई 'आवश्यक =' आवश्यक 'पैरामीटर नहीं है। – Eray
zf2 के साथ, inputFilterSpecification में कहें कि फ़ील्ड या फ़ील्ड का समूह आवश्यक है, इसका मतलब यह नहीं है कि एक विशेषता HTML में सेट की गई है, यह केवल $ form-> isValid() करते समय सत्यापन के लिए है, यह सभी आवश्यक फ़ील्ड की जांच करेगा सत्यापन के भीतर समूह – Hooli
इसलिए मुझे भी आवश्यक विशेषता सेट करने की आवश्यकता है। मैंने सोचा कि 'मूल्य [विशेषताओं] [आवश्यक] = सत्य' 'आवश्यक = आवश्यक' एचटीएमएल विशेषता – Eray