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

    xbille

    07/09/2021, 9:05 AM
    public function messages() { $fields = [ 'color' => 'required|string', 'hide_menu' => 'boolean', 'hide_cta' => 'boolean', 'unlink_logo' => 'boolean', 'title' => 'required|string|max:200', ]; $messages = [ 'title.required' => "The title is required", 'color.required' => "Color is required" ]; return $this->messagesForTranslatedFields($messages, $fields); }
  • x

    xbille

    07/09/2021, 9:06 AM
    dont work 😕
  • i

    ifox

    07/09/2021, 9:06 AM
    that's not how it works
  • i

    ifox

    07/09/2021, 9:06 AM
    the first parameter is messages for non translated rules, second is for translated rules, exactly like you did with the other helper above
  • x

    xbille

    07/09/2021, 9:07 AM
    okay ... you mean the missing "required" tag at HTML form field in Twill generated form fields? I see. 😕
  • v

    void

    07/09/2021, 9:08 AM
    Don't mind me, just try to do what ifox is saying
  • x

    xbille

    07/09/2021, 9:10 AM
    okay... why the parameter is named $fields? you mean it so:
  • x

    xbille

    07/09/2021, 9:10 AM
    public function messages() { $notTranslatedMessages = [ 'color.required' => "Color is required" ]; $translatedMessages = [ 'title.required' => "The title is required", ]; return $this->messagesForTranslatedFields($notTranslatedMessages, $translatedMessages); }
  • i

    ifox

    07/09/2021, 9:14 AM
    yes, that should work. if not, there's definitely a bug
  • x

    xbille

    07/09/2021, 9:16 AM
    unfortunately not
  • i

    ifox

    07/09/2021, 9:16 AM
    can you check the response in your network tab/console?
  • x

    xbille

    07/09/2021, 9:18 AM
    oh...there it is: {"message":"The given data was invalid.","errors":{"color":["Color is required"]}}
  • x

    xbille

    07/09/2021, 9:36 AM
    hhmm...custom rules also dont work with the message at the field. in twill 2.1.1 it works, in 2.4 dont .. probably its a new bug with 2.4?
  • i

    ifox

    07/09/2021, 9:37 AM
    definitely sound like a regression, would you mind reporting on GitHub issues so that we can keep track of it? thanks, and sorry for the trouble...
  • x

    xbille

    07/09/2021, 9:38 AM
    sure, i do 🙂
  • j

    Joyce

    07/09/2021, 9:45 AM
    @User it's working for me with this code
  • j

    Joyce

    07/09/2021, 9:45 AM
    Copy code
    php
    public function rulesForUpdate()
    {
        return $this->rulesForTranslatedFields([
            'start_date' => 'required',
        ], [
            'url' => 'required',
        ]);
    }
    public function messages()
    {
        return $this->messagesForTranslatedFields([
            'start_date.required' => 'custom date required message',
        ], [
            'url.required' => 'custom translated URL required message',
        ]);
    }
  • x

    xbille

    07/09/2021, 10:08 AM
    oh! with Twill 2.4?
  • j

    Joyce

    07/09/2021, 10:10 AM
    yes
  • x

    xbille

    07/09/2021, 10:59 AM
    aahh .. I found my mistake. in our project we have in twill.php "bind_exception_handler = false" without the twill Handler. Thats it. Thanks to all of you!
  • b

    bwaltz6

    07/09/2021, 4:49 PM
    Having trouble with repeaters. I have a menu model and a menuItem model. The menu model hasMany menuItems and menuItems hasOne menu. There's already a menus table, a menu_items table, and a pivot table. However, when following the thread here: https://github.com/area17/twill/issues/131 I get some foreign key errors when trying to do pretty much anything
  • b

    bwaltz6

    07/09/2021, 4:49 PM
    Adding the override functions to my MenuRepository is what triggers the error
  • b

    bwaltz6

    07/09/2021, 4:51 PM
    Is that github thread still relevant? It says so in the docs
  • p

    pboivin

    07/09/2021, 4:55 PM
    Hey @User , I think the thread can still be helpful but there was a little update to the docs recently (not yet online). Have a look : https://github.com/area17/twill/blob/2.x/docs/.sections/form-fields.md#repeater
  • p

    pboivin

    07/09/2021, 4:59 PM
    The example doesn't use a pivot table, just a foreign key on the repeater item table.
  • b

    bwaltz6

    07/09/2021, 5:47 PM
    oh awesome! Let me take a look
  • b

    bwaltz6

    07/09/2021, 5:53 PM
    nice!
  • b

    bwaltz6

    07/09/2021, 5:53 PM
    works
  • b

    bwaltz6

    07/09/2021, 5:53 PM
    🙏 thanks!
  • b

    bwaltz6

    07/09/2021, 6:01 PM
    so in my case menuItems can be nested. Would I use some of the same code to get nested menuItems to display?
1...575859...484Latest