Jump to content
zaib

select option field is not saving

Recommended Posts

I'm trying to save a select field with single select option but after clicking on save button i got error page, data in select options is more than 6000

 

10.50.200.58 processwire setup field save.png

Share this post


Link to post
Share on other sites

You have more than 6000 options in the select field? I would say if that's the case you should switch to using Pages and Page Reference. 

  • Like 2

Share this post


Link to post
Share on other sites

@Tom. yes more than 6000, basically i'm select option is holding all airport  city code like 'LHR,DXB,LAX etc..'. for page references do i need to create 6000 pages?

Share this post


Link to post
Share on other sites
2 hours ago, zaib said:

@Tom. yes more than 6000, basically i'm select option is holding all airport  city code like 'LHR,DXB,LAX etc..'. for page references do i need to create 6000 pages?

I would encourage to do that, it also means you can use something like Page Auto Complete so you don't have to scroll through a huge dropdown trying to find the airport you are looking for but instead you can just type it out. 

  • Like 3

Share this post


Link to post
Share on other sites

The easiest is probably to use a module like this https://modules.processwire.com/modules/import-pages-csv/

To avoid timeout errors, you maybe have to split your data into smaller chunks, and/or temporarily increase PHP script execution time + memory.

Writing a script yourself would look a bit like this (of course you'd have to hold your data in an array and do a foreach)

https://processwire-recipes.com/recipes/create-page-via-api/

Helper library for parsing CSVs: https://github.com/parsecsv/parsecsv-for-php

  • Like 3

Share this post


Link to post
Share on other sites

@adrian's Admin Actions module is a good starting point as well, take a look at source code files, most of them are short and good examples how to work with the API, you can create your own "action" and run from the admin if you want to:

 

  • Like 1

Share this post


Link to post
Share on other sites
13 hours ago, zaib said:

@dragan how can i create 6k pages with AP, is there any processwire module ? can you help me in this.

thank you.

I would go with the import option in BatchChildEditor (https://processwire.com/talk/topic/6102-batch-child-editor/)

12 hours ago, dragan said:

Helper library for parsing CSVs: https://github.com/parsecsv/parsecsv-for-php

Batch Child Editor makes use of this library.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Mithlesh
      Hi there,

      On my website page: https://www.writerrelocations.com/about-us/governance-team/, attaching the snapshot for your reference: 



      I want the above one should be minimized and maximised when one click on the button(where the name is written); like in the reference below - it is minimized 



      Maximised Option:



      Kindly let me know how can we do the same?
    • By EyeDentify
      I as have been a bit confused for some time about how the "Markup Regions" functionality in Processwire worked.
      But i have know read a bit more and think that i am getting to grips with it. And Markup Regions is going to be huge.

      To aid me in understanding Markup Regions better i started to read the Source code for the new "Regular" theme in conjunction with the Blog about the markup regions.
      It helped me a great deal to understand the basics and more fine details of it.

      A tip is to open both links and use the Source code of the "Regular" theme while reading the blog post.
       
      The Source code:
      https://github.com/processwire/processwire/blob/dev/site-regular/templates/_main.php
      The Blog post:
      https://processwire.com/blog/posts/processwire-3.0.62-and-more-on-markup-regions/
       
      I hope this could help others starting out with markup regions.
      Just take it slow and read it a couple a times and soon you will see the greatness of markup regions.

      /EyeDentify 
    • By EyeDentify
      Hello Fellow PW Fans and Gurus.

      I have run into a problem where i have created a template without a template file associated with it.
      Now i would like to HAVE a template file associated with it, not an alternate but as the main template file.

      So i thought, that's easy, I upload the template file and change it in template settings but I only get the Alternate template file setting?

      Ok so maybe i can change it via the API , so i wrote some code for this.
      <?PHP function changeTemplate($pages = null, $templates = null) { /* get the pages to change template on */ $logItems = $pages->findMany('template=tmp_log_item'); /* get the template object for our desired template */ $Template = $templates->get('tmp_new_log_item'); foreach($logItems AS $key => $logData) { /* use template object $Template to set template */ $logData->template = $Template; /* save page item */ $logData->save(); } } /* do the magic change */ changeTemplate(); ?> Needless to say, PW was not happy about this, It throw up an error message:
      Error: Exception: Invalid value sent to Page::setTemplate (in /home/virtual/mydomain/public_html/wire/core/Page.php line 1782)
      Now from what i understand i gave $logData->template the wrong type of value.
      So what should the value be to correct this?
      When I read the docs at: https://processwire.com/api/ref/page/
      the value can be "string" or "Template".

      So i gave it a string and it went haywire.

      How should I approach this cause I realy dont want to manually change template file on över 50 plus pages

      Maybe I should use the Template class to create the value that the API wanted, but I am unsure how to use it.

      Thank you for any info you can give me on this.

      If you want more info to help me, ask and I will try my best to give it to you.
      Updated and Solved
      I solved the problem and have updated the code to reflect this.

      Essentialy i used the get() method of $templates to get the template object for my template i wanted to use using the template name.
      I gave the Object to the $logData->template property and all went well.
      We learn something new every day.
      One Note:
      The template file you want to use must have been uploaded and added as a template in the Template section in the Admin for this code to work as expected.
    • By Mustafa-Online
      MBR international is Sudanese mining company. The company aims to maximize shareholder value by through
      exploration and Production of precious metal and industrial mineral, MBR international mining subsidiary was established in 2015, engaged in Industrial Minerals and Metals mining and related activities including explorations, extraction and processing. 
      **************
       
       

       
       

       
    • By pwuser1
      First I am a PW student I think it's the best PHP Framework.  So please don't get me wrong when I asked when other Frameworks like the big 3 (Wordpress, Joomla, Drupal) are too complicated to use or maintain (I tried them all) why are people still using them? PW is just too elegant in comparison even for a newbie like me.
×
×
  • Create New...