Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8592923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:52:05+00:00 2026-06-11T23:52:05+00:00

I’ve spent a bunch of time trying to figure this problem out and had

  • 0

I’ve spent a bunch of time trying to figure this problem out and had zero luck. I have tried routing with no success. I’ll put the logic first then the code.

  1. Users are in /pra/Fields/view/1 looking at a list of fields where fields.template_id=1
  2. Users click add new field /pra/Fields/add_new/1 they are brought to a form where they enter the information they want to
    about the new field they create.
  3. when a user clicks on add/submit, the new field is saved to the database
  4. The user is taken back to /pra/Fields/view/1 so they can see the new field added to the template

currently the first 3 steps are happening, however when it comes to redirecting back to /pra/Fields/view/1 The user is being redirected to /pra/Fields/view/

here is the code for the add_new function

function add_new($id=null){
    //allows users to add another field to an existing template
    $this->set('title_for_layout', 'Create Fields');
    $this->set('stylesheet_used', 'homestyle');
    $this->set('image_used', 'eBOXLogoHome.png');
    $this->layout='home_layout';
    $name=$this->Field->field('template_id', array('template_id'=>$id));
    //if the field data saves
    $this->set('name',$name);
    if(($this->Field->save($this->data)))
    {   
        //user is redirected to fields/view/$name
        $this->redirect(array('controller'=>'Fields', 'action'=>'view',$name));
    }
    //sets the $id variable
    $this->set('id',$id);

here is the add_new view

<table id="formatform">
        </br></br>
        <?php
            $options = array('Money'=>'Money','Text'=>'Text','Description'=>'Description');
            ?>
        <?php echo $this->Form->create('Field', array('action'=>'add_new')); ?>
        <?php echo $this->Form->input('id',array('type'=>'hidden')); ?>
                <tr>
                <td></td>
                <td><?php echo $this->Form->input('template_id',array('type'=>'hidden','default' => $id)); ?></td>
                </tr>

                <tr>
                <td align='center'>Field Name:</td>
                <td align='left'><?php echo $this->Form->input('name', array('label'=>false)); ?></td>
                </tr>

                <tr>
                <td align='center'>Default Value:</td>
                <td align='left'><?php echo $this->Form->input('default_value', array('label'=>false)); ?></td>
                </tr>
                <tr>
                <td align='center'>Field Type:</td>
                <td align='left'><?php echo $this->Form->input('field_type', array('label'=>false,'type'=>'select','options'=>$options)); ?></td>
                </tr>

                <tr>
                <td align='center'>Description:</td>
                <td align='left'><?php echo $this->Form->input('description', array('label'=>false)); ?></td>
                <td><?php echo $this->Form->input('active', array('type'=>'hidden','default'=>true)); ?></td>
                </tr>




    <td></td>   <td align = "left"><?php echo $this->Form->end('Submit');?></td>

and here is the view function code

function view($name){
    //lists information about fields that correspond to the
    //template they have clicked 'view' on
    $this->set('title_for_layout', 'Field Details');
    $this->set('stylesheet_used', 'homestyle');
    $this->set('image_used', 'eBOXLogoHome.png');
    $this->layout='home_layout';
    //sets $conditions where template_id=$name and field.active=true
    $conditions=array(
        "AND"=>array(
        'template_id'=> $name,
        'Field.active'=>true));
    //finds all fields where 'conditions'=$conditions
    $fields = $this->Template->Field->find('all',array( 
        'conditions' => $conditions));
    //sets all the variables      
    $this->set('conditions', $conditions);
    $this->set('field', $fields);
    $this->set('field', $this->paginate('Field', $conditions));  


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:52:07+00:00Added an answer on June 11, 2026 at 11:52 pm

    It might happen that you have an issue here:

    function add_new($id=null){
        //allows users to add another field to an existing template
        $this->set('title_for_layout', 'Create Fields');
        $this->set('stylesheet_used', 'homestyle');
        $this->set('image_used', 'eBOXLogoHome.png');
        $this->layout='home_layout';
    

    Check if $name is not empty

    $name = $this->Field->field('template_id', array('template_id'=>$id)); 
    if(!empty($name)){
        $this->set('name',$name);
        if(($this->Field->save($this->data)))
        {   
            //user is redirected to fields/view/$name
            $this->redirect(array('controller'=>'Fields', 'action'=>'view',$name));
        }
    }
    

    the rest of your code

    //sets the $id variable
    $this->set('id',$id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.