jan-vince / smallrecords

OctoberCMS plugin to store and manage records and lists
MIT License
30 stars 11 forks source link

false is considered as a value #62

Open charles-tainui opened 4 years ago

charles-tainui commented 4 years ago

hello,

i've noticed that properties having default value set to "false" are considered as having a value when they are tested with "if" (ie : if ($this->property('useMainCategory')))

But value is set to zero when property checkbox is checked twice, once for checking, once for unchecking ; and then testing with "if" reacts as expected.

Hope i am clear … Regards

PS : thumbs up for your great development !

jan-vince commented 4 years ago

Hi @charles-tainui,

the type of this property (useMainCategory) is checkbox and all default values are true or false.

You have problems using this with any of component?

PS: I have set in RecordDetail default value to true while all others are false. Can this be the problem?

charles-tainui commented 4 years ago

hello @jan-vince ,

i've just tested to add Records component (as a snippet) to content field of a Staticpage, the initial code is : <figure data-component="\JanVince\SmallRecords\Components\Records" data-inspector-id="inspectorid-310544570422" data-property-activeonly="true" data-property-allowlimit="false" data-property-areaslug="parutions-presse" data-property-categoryslug="{{ :category }}" data-property-favouriteonly="false" data-property-limit="10" data-property-orderascollection="false" data-property-orderby="name" data-property-orderbydirection="ASC" data-property-pageslug="{{ :page }}" data-property-recordpage="false" data-property-recordpageslug="{{ :record }}" data-property-tagslug="{{ :tag }}" data-property-usemaincategory="false" data-property-usemulticategories="0" data-snippet="records">&nbsp;</figure> Nothing is displayed.

Then i replace "false" by "0" : <figure data-component="\JanVince\SmallRecords\Components\Records" data-inspector-id="inspectorid-310544570422" data-property-activeonly="true" data-property-allowlimit="0" data-property-areaslug="parutions-presse" data-property-categoryslug="{{ :category }}" data-property-favouriteonly="0" data-property-limit="10" data-property-orderascollection="0" data-property-orderby="name" data-property-orderbydirection="ASC" data-property-pageslug="{{ :page }}" data-property-recordpage="0" data-property-recordpageslug="{{ :record }}" data-property-tagslug="{{ :tag }}" data-property-usemaincategory="0" data-property-usemulticategories="0" data-snippet="records">&nbsp;</figure> and my records show up

i feel (an do not understand why) taht "false" is considered as a string instead of a boolean

jan-vince commented 4 years ago

Hi and thanks for your info.

I have never used that in Static Pages so I have no experience (bad or good).

But a problem with non-boolean false value is reported on GitHub - i will check that.

Best regards,

Jan

    1. 2020 v 19:18, CHAUVIN Charles notifications@github.com:

hello @jan-vince https://github.com/jan-vince ,

i've just tested to add Records component to content field of a Staticpage, the initial code is :

 

Nothing is displayed.

Then i replace "false" by "0" :

 

and my records show up

i feel (an do not understand why) taht "false" is considered as a string instead of a boolean

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jan-vince/smallrecords/issues/62#issuecomment-601338185, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAINT757E5CX5KN2TZCZETLRIJOXJANCNFSM4KKHVP7A.