fulcrologic / fulcro-rad

Fulcro Rapid Application Development
MIT License
201 stars 46 forks source link

field-labels not handle as function #129

Closed schneiderlin closed 1 week ago

schneiderlin commented 2 weeks ago

https://github.com/fulcrologic/fulcro-rad/blob/1f08ec89e04249b7fba8307c067b6955162828ee/src/main/com/fulcrologic/rad/form.cljc#L1752C1-L1773C18

docstring says

::form/field-labels: A map from attribute keyword to a string or function returning a string.

but (get-in options [::field-labels k]) only handle field-labels as a map

awkay commented 1 week ago

Look again. ?! is a helper that does just that, and it is present in the code you referenced:


...
        field-label (?! (or
                          (get-in options [::field-labels k])
                          (::field-label attribute)
                          (ao/label attribute)
                          (some-> k name str/capitalize (str/replace #"-" " "))) form-instance)]
...
awkay commented 1 week ago

perhaps you misunderstood...it is:

{:k (fn ...)
 :k2 (fn ...)}

not (fn [...] {:k val :k2 val})

schneiderlin commented 1 week ago

thank you for the clarification, I try :field-labels (constantly "label") without success, so it should be :field-labels {:k (constantly "label")}

awkay commented 1 week ago

It does not need to be a function...it can just be a string. Look at what ?! does.

On Sun, Oct 13, 2024 at 6:51 PM Lin ZiHao @.***> wrote:

thank you for the clarification, I try :field-labels (constantly "label") without success, so it should be :field-labels {:k (constantly "label")}

— Reply to this email directly, view it on GitHub https://github.com/fulcrologic/fulcro-rad/issues/129#issuecomment-2409671489, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI7L66JEQ2OSNSEHXFHWHDZ3MPRHAVCNFSM6AAAAABPW76772VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBZGY3TCNBYHE . You are receiving this because you modified the open/close state.Message ID: @.***>