https://twill.io logo
Join Discord
Powered by
# ❓questions
  • h

    Harings Rob

    08/16/2022, 8:06 AM
    Sorry @delta107 I think you need to provide more information. What is the issue you are working on?
  • d

    delta107

    08/16/2022, 8:07 AM
    @Harings Rob Yeah sure. So I am trying to add validation to repeater fields but it displays only the red band, and it doesdn't display the line underlined with green(in screenshot)
  • d

    delta107

    08/16/2022, 8:08 AM
    I tried to edit messages function to no avail
  • h

    Harings Rob

    08/16/2022, 8:09 AM
    So the message appears, but it is not showing your custom content?
  • d

    delta107

    08/16/2022, 8:11 AM
    The content appears. Do you see the difference from above. Now it's a repeater field
  • d

    delta107

    08/16/2022, 8:11 AM
    And it shows only the red band
  • h

    Harings Rob

    08/16/2022, 8:11 AM
    Ok, let me try to reproduce.
  • h

    Harings Rob

    08/16/2022, 8:14 AM
    is it a translatable field?
  • d

    delta107

    08/16/2022, 8:15 AM
    Yes
  • h

    Harings Rob

    08/16/2022, 8:17 AM
    last question, is it a json repeater?
  • d

    delta107

    08/16/2022, 8:25 AM
    no, simple repeater
  • h

    Harings Rob

    08/16/2022, 8:36 AM
    So, I did a minimal setup. (https://twill.io/docs/form-fields/repeater.html#using-repeater-fields) and added a translatable rule and all seems to work fine.
  • h

    Harings Rob

    08/16/2022, 8:37 AM
    What does not work is json repeaters.
  • h

    Harings Rob

    08/16/2022, 8:37 AM
    Copy code
    php
        public function rulesForUpdate()
        {
            return $this->rulesForTranslatedFields([], ['repeaters.team-member.*.title' => 'required']);
        }
  • d

    delta107

    08/16/2022, 8:41 AM
    Hmm okay, I will try to reinspect the code maybe I made a mistake somewhere, thanks!
  • h

    Harings Rob

    08/16/2022, 8:42 AM
    Keep in mind the distinction between rulesForUpdate and rulesForCreate
  • h

    Harings Rob

    08/16/2022, 8:42 AM
    Rules need to be in the request class.
  • b

    BA7YA

    08/16/2022, 8:47 AM
    Hi. I left bug report https://github.com/area17/twill/issues/1775 . Hope we will find solution soon 🤞
  • d

    delta107

    08/16/2022, 8:47 AM
    @Harings Rob Could this be related to the fact that it's a singleton module?
  • h

    Harings Rob

    08/16/2022, 8:47 AM
    It should not.
  • h

    Harings Rob

    08/16/2022, 8:48 AM
    If you can make a minimal reproducable repo I am happy to look into it more.
  • d

    delta107

    08/16/2022, 8:55 AM
    Is there a way to make a field disabled but only on update?
  • d

    delta107

    08/16/2022, 8:55 AM
    https://twill.io/docs/form-fields/input.html disabled Disables the field true false false
  • k

    kalle

    08/16/2022, 8:57 AM
    I dont realy understand what you mean by 'only on update'. Can you describe wanted scenario?
  • d

    delta107

    08/16/2022, 8:57 AM
    I meant that you fill in a field on create but disable it while editing
  • h

    Harings Rob

    08/16/2022, 8:57 AM
    @delta107 I think you can use this in your controller:
    Copy code
    /*
         * Add anything you would like to have available in your module's form view
         * For example, relationship lists for multiselect form fields
         */
        protected function formData($request)
        {
            return [];
        }
  • h

    Harings Rob

    08/16/2022, 8:58 AM
    in twill 3.x this is easier if you have the form fields in the oop way
  • k

    kalle

    08/16/2022, 9:00 AM
    If thats the module, then you have 2 view files. One for create form and second is view/ edit form in which you can manualy disable wanted fields. Or like @Harings Rob sent you, you can pass conditional variable to the input which will set wanted state (enabled or disabled)
  • h

    Harings Rob

    08/16/2022, 9:31 AM
    Ok that's a much better answer. There is only a create and an update form 🥲
  • s

    Sami

    08/16/2022, 7:37 PM
    🥺
1...374375376...484Latest