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

    user

    07/09/2021, 6:16 AM
    I feel there will be more developer control... if all the files are readily available at their specific folders. For example, config/twill.php with all values instead of being empty... similarly, all index, show, edit, create files in the view folder... it becomes a lot easier just edit and see the output... instead of searching or finding out ways to modify these files... keep all the files in the /app/ folder may increase the adoption i feel..... Would like to know if this was a planned approach and why...
  • i

    ifox

    07/09/2021, 6:44 AM
    Everything you're asking for is already possible through Laravel features which Twill is not preventing you to use: you can publish the whole config if that's what you're after, but it's not recommended. You can publish all views too, but then you're on your own to maintain them.
  • x

    xbille

    07/09/2021, 8:01 AM
    Hey! I found in the Twill doc custom validations messages, but I have no idea how exactly I can use them, can someone help me? Or I like to use the predefined ones in the translation file. The main thing is that the validation error is displayed at the form field.
  • i

    ifox

    07/09/2021, 8:05 AM
    hey @xbille do you mean you'd like to translate them? Or change the English version too?
  • x

    xbille

    07/09/2021, 8:06 AM
    I want to use them directly on the form field. 🙂 It works great for individual rule classes, but not for standard rules like 'required'.
  • i

    ifox

    07/09/2021, 8:11 AM
    https://laravel.com/docs/8.x/validation#customizing-the-error-messages
  • i

    ifox

    07/09/2021, 8:12 AM
    https://github.com/laravel/laravel/blob/8.x/resources/lang/en/validation.php
  • i

    ifox

    07/09/2021, 8:12 AM
    you can edit this default Laravel file in your application too
  • x

    xbille

    07/09/2021, 8:14 AM
    I have seen this files, thank you. 🙂 But I want to use them in default validation like required. Currently the validation error is displayed at the bottom and not like custom validation directly at the form field.
  • x

    xbille

    07/09/2021, 8:15 AM
    like here ... the Page Type field is required.
  • i

    ifox

    07/09/2021, 8:16 AM
    oh, in the create modal, ok, that makes sense. well it's not supported there at the moment
  • i

    ifox

    07/09/2021, 8:16 AM
    in the form what you describe would work
  • x

    xbille

    07/09/2021, 8:16 AM
    not only in the modal, also in update form 🙂
  • i

    ifox

    07/09/2021, 8:17 AM
    well that field is still in the modal
  • i

    ifox

    07/09/2021, 8:17 AM
    if you put it on the form the error will show next to it
  • i

    ifox

    07/09/2021, 8:18 AM
    or do you mean for the color field here?
  • i

    ifox

    07/09/2021, 8:18 AM
    how do you set that validation rule in the form request?
  • x

    xbille

    07/09/2021, 8:25 AM
    At the second example the color field is not in the modal 🙂
  • i

    ifox

    07/09/2021, 8:26 AM
    yeah got it, can you share your form request class?
  • x

    xbille

    07/09/2021, 8:28 AM
    I think i can use the $this->messagesForTranslatedFields() method? but how? 😅
  • i

    ifox

    07/09/2021, 8:30 AM
    thanks, yes, inside of the
    messages
    function
  • x

    xbille

    07/09/2021, 8:31 AM
    okay thanks and how I can integrate the function?
  • i

    ifox

    07/09/2021, 8:32 AM
    I'm not sure what you mean. Laravel form requests have a messages function that you can implement. In there, you can call Twill's helper and return it's result
  • x

    xbille

    07/09/2021, 8:45 AM
    can you show me an example please?
  • v

    void

    07/09/2021, 8:49 AM
    https://laravel.com/docs/8.x/validation#customizing-the-error-messages
  • x

    xbille

    07/09/2021, 8:50 AM
    Copy code
    public function messages()
        {
            return  [
                'title.required' => "The title is required",
                'color.required' => "Color is required"
            ];
        }
  • x

    xbille

    07/09/2021, 8:51 AM
    for my code .... dont work 😦
  • v

    void

    07/09/2021, 8:51 AM
    Directly on the field validation isn't laravel specific it's the HTML5 validation tho. where HTML5 will not submit a form if something required isn't filled, or a type="email" input doesn't seem to have an email string in there etc
  • i

    ifox

    07/09/2021, 9:05 AM
    @xbille you need to call the helper. I'm on mobile right now so can't share a nice snippet but basically return
    $this->messagesForTranslatedFields(...)
    inside of
    messages
  • x

    xbille

    07/09/2021, 9:05 AM
    i try 😅
1...565758...484Latest