Juergen Posted September 27, 2017 Share Posted September 27, 2017 It would be great if "required if" conditions in repeaters inputfield dependencies will work in the future. At the moment only "show if" conditions work. Today I have implemented the new fieldset (Page) type, which works like a repeater. But unfortunately I had to remove it because of the non working "required if" conditions. In my case I need the "required if" condition and therefore I had to switch back to a default fieldset (which supports the "required if" condition dependency). But it was more work and I needed more fields. So this feature would save a lot of time. Maybe it will be possible in the near future. Would be great! 1 Link to comment Share on other sites More sharing options...
bernhard Posted September 27, 2017 Share Posted September 27, 2017 6 hours ago, Juergen said: But unfortunately I had to remove it because of the non working "required if" conditions. In my case I need the "required if" condition and therefore I had to switch back to a default fieldset (which supports the "required if" condition dependency). But it was more work and I needed more fields. why don't you use a hook to set the required attribute based on your condition? sounds easier than your way 1 Link to comment Share on other sites More sharing options...
Juergen Posted September 27, 2017 Author Share Posted September 27, 2017 Because I would have to write a lot of hooks and that is what I want to prevent . Link to comment Share on other sites More sharing options...
tpr Posted September 28, 2017 Share Posted September 28, 2017 What is the condition you wanted to use? Link to comment Share on other sites More sharing options...
Juergen Posted September 28, 2017 Author Share Posted September 28, 2017 I have created a set of inputfields for recurring events. There you can choose between daily, weekly, monthly yearly and you can choose between an enddate or a number of repeats (and of course some other options). The if condition depends on a select option fieldtype. If you choose "repeat until a certain enddate" then the enddate field needs to be filled out (required), if you choose to repeat the events until a certain number of repeats (fe 10 repeats), then the enddate field is not required. All the fields are in the new fieldset(Page) fieldtype. Link to comment Share on other sites More sharing options...
abmcr Posted November 26, 2017 Share Posted November 26, 2017 On 27/9/2017 at 2:28 PM, bernhard said: why don't you use a hook to set the required attribute based on your condition? sounds easier than your way Hello. I have the same problem: i want to require a filed into a repeater.... an hook?... do you may put a simple approach? I have try with this not working code into ready.php $wire->addHookAfter('FieldtypeRepeater::savePageField', function($event) { $items=($event->arguments[0]->links_utili); foreach ($items as $key) { if (empty(trim($key->title)) || empty(trim($key->url_link)){ //i need to remove the field and show a warning message } } }); I have a repeater named links_utili with 3 fields: title, url_link, active and i want to require url for each title This is the correct approach or is better to implement $this->addHookBefore('Pages::save', function(HookEvent $event) Thank you Link to comment Share on other sites More sharing options...
Robin S Posted November 27, 2017 Share Posted November 27, 2017 On 27/11/2017 at 3:52 AM, abmcr said: i want to require a filed into a repeater Required fields work fine in a repeater. From what I have tested, "required if" dependencies also seem to work fine in a repeater. What problem do you get if you make the url_link field required in your repeater? Link to comment Share on other sites More sharing options...
DV-JF Posted March 3, 2020 Share Posted March 3, 2020 It's an old topic, but I have nearly the same problem: When using condition the conditon "required if" I'll get an error displayed: Quote FieldtypeRepeaterConfigHelper: Repeater-Feld "images" hat in den Einstellungen eine Bedingung "Pflichtfeld nur wenn", dies wird in Repeatern nicht unterstützt. +1 FieldtypeRepeaterConfigHelper: Repeater-Feld "videos" hat in den Einstellungen eine Bedingung "Pflichtfeld nur wenn", dies wird in Repeatern nicht unterstützt. but it seems to work ? Unfortunately I was wrong, when saving the page PW tells me that all these fields are required : @ryan Could you shortly explain why we can't use "required if" conditions in repeater fields and if this may change in the nearer future? Many greets ! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now