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 8836581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:31:45+00:00 2026-06-14T09:31:45+00:00

I have a cakephp 1.3 app which get’s a person’s consent to participate in

  • 0

I have a cakephp 1.3 app which get’s a person’s consent to participate in a study. I’m trying to link inclusion criteria and exclusion criteria for the study on the Add study page. The HABTM relationship is setup and working(If there’s only one way to select them) What I’m trying to do now is display the current Inclusion Criteria as a list of checkboxes the person adding the study can select, but I also want a field where new criteria can be entered as a comma seperated list. Right now it will save the checkboxes, but I want it to also add the text entered in the field as well. Screen showing the Add study as it sits now is below. I don’t really know how I would go about doing that. Is there a way to do this or will I have to take the data entered, sort through it and then add it to $this->data[inclusion field data]? An example would be nice. 🙂 I’ve added the code I have so far below the image. Add Study Screen

Controller:

/**
   * Add a study.
   */
  function add() {
    if (!empty($this->data)) {

      //get the inclusions from the text data
      //Sort through the comma seperated list and add it to $this->data['Study']['Inclusions']???

      $this->Study->create();
      if ($this->Study->save($this->data)) {
        $this->Session->setFlash(__('The study has been saved', true));
        $this->redirect(array('action' => 'index'));
      } else {
        $this->Session->setFlash(__('The study could not be saved. Please, try again.', true));
      }
    }
    $this->set('inclusions', $this->Study->Inclusion->find('list', array(
      'fields' => array('id', 'name'), 
      'order' => 'Inclusion.name', 
      'recursive' => 0,
    )));
    $this->set('exclusions', $this->Study->Exclusion->find('list', array(
      'fields' => array('id', 'name'), 
      'order' => 'Exclusion.name', 
      'recursive' => 0,
    )));
    $this->set('forms', $this->Study->Form->find('list', array('order' => 'Form.name','recursive' => 0,)));
  }

View:

<div class="studies form">
<?php echo $this->Form->create('Study', array('type' => 'file'));?>
  <fieldset>
    <legend><?php __('Add Study'); ?></legend>
  <?php
    echo $this->Form->input('studyname', array('label'=>'Study Name','required' => true));
    echo $this->Form->input('studynumber', array('label'=>'Study Number','required' => true));
    echo $this->Form->input('file', array('label'=>'Select Electronic Consent','type' => 'file'));
    echo $this->Form->input('consent_form_date');
  ?>
   <fieldset class="inclusion">
    <legend><?php __('Inclusions'); ?></legend>
   <div class="IncExc">
  <?php
    echo $this->Form->input('Inclusion',array(
        'label' => false,
        'type' => 'select',
        'multiple' => 'checkbox',
        'options' => $inclusions,
        'selected' => $html->value('Inclusion.Inclusion'),
    ));
  ?>
  </div>
  <?php
    echo $form->input('Inclusion.inclusions',array(
            'type' => 'text',
            'label' => __('Add New Inclusions',true),
            'after' => __('Seperate each new Inclusion with a comma.  Eg: family, sports, icecream',true)
    ));
  ?>
  </fieldset>
  <fieldset>
    <legend><?php __('Exclusions'); ?></legend>
   <div class="IncExc">
    <?php
    echo $this->Form->input('Exclusion',array(
        'label' => false,
        'type' => 'select',
        'multiple' => 'checkbox',
        'options' => $exclusions,
        'selected' => $html->value('Exclusion.Exclusion'),
    ));
 ?>
  </div>
  </fieldset>
  <fieldset style="width: 700px;">
    <legend><?php //__('Forms'); ?></legend>
    <?php /*
    echo $this->Form->input('Form',array(
        'label' => false,
        'type' => 'select',
        'multiple' => 'checkbox',
        'options' => $forms,
        'selected' => $html->value('Form.Form'),
    ));
*/ ?>
  </fieldset>
  </fieldset>
<?php echo $this->Form->end(__('Submit', true));?>
</div>
  • 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-14T09:31:46+00:00Added an answer on June 14, 2026 at 9:31 am

    You are trying to do pretty much the same as he wanted to do: Saving tags into a database table in CakePHP

    What you have to do is:

    1. Check if the manual inclusion field is empty or not. If the field is empty ignore it and go to step 5
    2. If the field is not empty, split it at comma or whatever sign you want to use as a seperator. You can now validate it if you want to.
    3. Use all the inclusions of step 3 and save them in your custom or real inclusion table. You should keep track of those custom entries in some way, so you don’t mess them up with those you provided. Save all the ids generated while saving within an array.
    4. Merge the collected ids of step 3 with those you got from the form which were given by you.
    5. Save all collected and given data to database

    The answere in the post given above including the code there can be used to do that. You should get along with it pretty well if you read the whole post + code comments 😉

    If you have any further questions, just ask 😉

    Greetings
    func0der

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have CakePHP app in which I'd like to attach gallery to multiple resources.
I have a cakephp 1.2 app (1.2.2.8120) and I am trying to change the
I have a local cakephp 1.2 app which was working fine last night. Currently
I have a CakePHP app which I have been developing on a remote server.
I have built a CakePHP app that creates appointments which have both a client
I have a CakePHP app that is being moved to Sql Server from MySql.
We have a cakephp app running on 2.0 and we seem to be having
I have a simple cakephp app with table articles that has a cat_id column
I have an issue with using the following code in my CakePHP app. In
Please have a look at this validation array in my cakephp app for model

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.