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

    zynth

    09/22/2022, 11:05 AM
    Hi @mateoD, you can implement a function that gets all the blocks of your module in it's corresponding repository like so:
    Copy code
    php
    $this->model->blocks()->get();
  • z

    zynth

    09/22/2022, 11:06 AM
    You can then just iterate over them and call the blocks input method
  • i

    ifox

    09/22/2022, 11:06 AM
    not necessarily, it really depends on your needs. The same function can probably be used to render any of your blocks by taking parameters.
  • i

    ifox

    09/22/2022, 11:08 AM
    I was responding to @mateoD, just to be clear, what @zynth is saying is correct too. though this code will query the db which you don't necessarily need if you already have a model variable you can access
    ->blocks
    without parentheses to avoid n+1 queries if they are already loaded. But that's optimization.
  • z

    zynth

    09/22/2022, 11:09 AM
    Oh sure no worries, you're right. In my case I needed to query a specific type of block so that's why I used blocks().
  • m

    mateoD

    09/22/2022, 2:03 PM
    in this way, we only get the content of the block, we cannot render it together with the html of the block, so I should create html where i want to use this content am i right ?
  • i

    ifox

    09/22/2022, 2:04 PM
    yes, and you can render it with something like
    view($view, $data)->with('block', $block)->render()
  • m

    mateoD

    09/22/2022, 2:07 PM
    I did it this way, it gives me an error
    Copy code
    Call to undefined method A17\Twill\Models\Block::hasActiveTranslation()
  • m

    mateoD

    09/22/2022, 2:29 PM
    i fixed it $item inside the loop foreach caused me problem
  • m

    mateoD

    09/23/2022, 8:01 AM
    hello trying to save a checkbox value in module Settings in dashboard returns me an error
    Copy code
    Array to string conversion
    . Do you have any idea why this happens, because only the checkbox gives an error ?
  • k

    kalle

    09/23/2022, 8:42 AM
    Do you work on default Settings module from Twill?
  • i

    ifox

    09/23/2022, 8:48 AM
    settings in Twill 2 are quite limited and don't support checkbox fields, you can use a select field instead (with 2 values, yes/no, enabled/disabled, something like that depending on your use case). They have been refactored in Twill 3 to support everything.
  • m

    mateoD

    09/23/2022, 9:12 AM
    ok thanx changed it to a select form
  • m

    mooff

    09/23/2022, 2:54 PM
    is it possible to make a dropdown field change the type of another field? e.g. to let the user choose "Text", "Number", "Currency", etc
  • m

    mooff

    09/23/2022, 2:59 PM
    in fact i may not need that, letting the server cast it should be enough :-)
  • i

    ifox

    09/23/2022, 3:09 PM
    Hey @mooff you could use connected fields for that
  • m

    mooff

    09/23/2022, 3:09 PM
    thanks @ifox, that gives me a helpful search term
  • c

    ckmirafss

    09/23/2022, 10:50 PM
    Hi, good day! When creating new module. How to change the default title into somethin like username?
  • c

    ckmirafss

    09/24/2022, 1:07 AM
    Does anyone encountered this? I removed the title and used the user_login.
  • v

    vladimir_mvs

    09/24/2022, 3:53 PM
    Hi guys! Please help me to solve two tasks 1) I need to add custom bulk action on the listing page. For example, "Export selected elements". It's important for me 2) I need to add similar "Export" button to each row's actions on the listing page. It nice to have, but not critical for me. I'm using Twill 2.9 and can upgrade to 3. I know how to register custom route and write action's logic in the controller, but I'm stuck with interface buttons.
  • h

    Harings Rob

    09/26/2022, 6:11 AM
    Hey @vladimir_mvs, I might be wrong but I believe this may not be possible at the moment. Checking a bit now.
  • h

    Harings Rob

    09/26/2022, 6:16 AM
    I have converted your discussion post into an issue to work on this in the future. https://github.com/area17/twill/issues/1832 But maybe others will provide tips thorough the day as I am pretty sure similar needs were there in the past.
  • o

    onepiece

    09/26/2022, 12:06 PM
    Hello guys. How can I get the value I put in a block in the controller? For example, I have the contactForm block in which I input the email. Now how can I get the value I set in the controller??
  • h

    Harings Rob

    09/26/2022, 12:41 PM
    Hey @onepiece you can use $block->input('yourfield')
  • o

    onepiece

    09/26/2022, 12:43 PM
    Does it work inside the controller??
  • h

    Harings Rob

    09/26/2022, 12:43 PM
    In your controller you will need to get the block and then extract the value.
  • h

    Harings Rob

    09/26/2022, 12:43 PM
    See https://discord.com/channels/811936425858695198/811986149064441927/1022509520259391539
  • o

    onepiece

    09/26/2022, 12:44 PM
    "message": "Class \"Leads\\Twill\\Capsules\\Leads\\Http\\Controllers\\Web\\A17\\Twill\\Services\\Blocks\\Block\" not found",
  • h

    Harings Rob

    09/26/2022, 12:46 PM
    Sorry @onepiece I cannot help you if you show some code that you already created.
  • h

    Harings Rob

    09/26/2022, 12:51 PM
    You need to call$lead->blocks()
1...405406407...484Latest