hellomoto Posted April 3, 2017 Share Posted April 3, 2017 I have a module here https://bitbucket.org/chimmel/pw-import-shorthand that I am using to create an image field like so: $mf[] = [[ 'tags' => $tag, 'name' => $pre.'logo', 'type' => wire('modules')->get('FieldtypeImage'), ],[ 'label' => 'Logo', 'columnWidth' => 50, 'inputfieldClass' => 'InputfieldImage', ]]; Yet upon its creation, initially, when I try creating a page of a template including it, it says that the field must first be configured. Once I go and save the field as-is, everything's honkey dory. It's just an annoyance, with every image field. I figured it would be the required inputfieldClass field field, but as you can see, that's included up in there, and it's still not good to go off the bat. Any clue as to why? Link to comment Share on other sites More sharing options...
adrian Posted April 3, 2017 Share Posted April 3, 2017 It's probably the valid extensions and missing max files settings - take a look at the Details tab of an image field. I would set those and maybe also the formatted value setting. 1 Link to comment Share on other sites More sharing options...
kixe Posted April 3, 2017 Share Posted April 3, 2017 @adrian Its only the extensions. maxFiles and outputFormat is set to 0 ((int) NULL) by default. @hellomoto No need to set inputfieldClass. The following is enough to get it work. $f = new Field; $f->name = 'myfield'; $f->type = 'FieldtypeImage'; $f->extensions = 'gif jpg jpeg png'; $f->save(); 2 Link to comment Share on other sites More sharing options...
Laikmosh Posted September 25, 2018 Share Posted September 25, 2018 and how can i set the formatted value of an image file created via API (auto, single, multi, string)? Link to comment Share on other sites More sharing options...
adrian Posted September 25, 2018 Share Posted September 25, 2018 6 hours ago, Laikmosh said: and how can i set the formatted value of an image file created via API (auto, single, multi, string)? Go to the field edit page in the PW admin and then in TracyDebugger open the RequestInfo panel. This shows you all the properties currently set for a field. Just use these in the API as needed. 2 Link to comment Share on other sites More sharing options...
adrian Posted September 25, 2018 Share Posted September 25, 2018 You could also use the Field Code section (created by @bernhard) which lets you copy / paste the API code need to create the field. Be sure to grab the very latest version of Tracy because I just committed a fix to this feature. It was previously missing certain properties. Note that this option is not enabled in Tracy by default so you need to go to the module settings and enable: 3 Link to comment Share on other sites More sharing options...
bernhard Posted September 25, 2018 Share Posted September 25, 2018 21 minutes ago, adrian said: I just committed a fix to this feature. It was previously missing certain properties. awesome, thx ? 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now