Jump to content
Larry Ullman's Book Forums

Jonathon

Members
  • Posts

    1064
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Jonathon

  1. It's a great resource. Yes I know, that's why I up-voted Larry's post with it in
  2. I've been thinking about having a site-wide SSL. I've read some things about it and just wanted to start a discussion. http://security.stackexchange.com/questions/258/what-are-the-pros-and-cons-of-site-wide-ssl-https http://security.stackexchange.com/questions/7790/guidance-for-implementors-of-https-only-sites-server-side
  3. I liked your comment purely for the word "quixotic". That's a keeper. http://regexlib.com/
  4. Hello gents, It was an interesting read Edward - Thank you. I will take on authentication when Larry's next update comes through. The main thing for me in this was just how you use a Yii session value in an attribute, rather than a user input. So $model->setAttribute was a nice little find.
  5. Ok, I have been looking at the framework code, it appears that you can do it with $model->setAttribute('user_id', 1); (I haven't done logging in yet, so that's why I haven't used the $_SESSION vairables). So I just hard coded the user_id public function actionUpdate($id) { $model=$this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if(isset($_POST['Item'])) { $model->attributes=$_POST['Item']; $model->setAttribute('user_id', 1); if($model->save()) $this->redirect(array('view','id'=>$model->id)); } $this->render('update',array( 'model'=>$model, )); }
  6. Well it's not so much setting the variables. It's how to use them to update/create a record, for instance to controller code for updating is: public function actionUpdate($id) { $model=$this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if(isset($_POST['Item'])) { $model->attributes=$_POST['Item']; if($model->save()) $this->redirect(array('view','id'=>$model->id)); } $this->render('update',array( 'model'=>$model, )); } But how do you use a value that doesn't come from a form in the updating process? On a total side note. I was so shocked at how little coding was needed to populate a form and update it. Because other than fix a few inputs into select boxes. I. Did. Nothing. This actually stresses me out, like it can't be that easy. Or is that a classic primer to "Yes It Is"?
  7. Hi, I've been playing with forms. I've used some sample data and have just been updating them. I plan to have a login system (surprising I know!) so only a user can add content. One of my fields is a user_id FK field. I noticed when it came to updating it populates the user_id input field and asks for a value ( because i put it in my rules) for this. But I was looking into my model and controller and I wasn't sure how you'd go about setting an attribute through a $_SESSION. I suspect that when I make the login system i'l;l set a $_SESSION['user_type'] and $_SESSION['user_id'] value and then planned to just confirm the existence of these and use them for insert/updating records. But in Yii, I was a bit lost as to how to do this
  8. It should be where your index.php file is stored. <ifModule mod_rewrite.c> # Turn on the engine: RewriteEngine on # Do not perform redirects for files and directories that exist: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # For everything else, redirect to index.php: RewriteRule . index.php </ifModule>
  9. Hello, My feedback form works. Which is great. I wanted to have a satisfaction rating (1-10) just radio buttons. So I started to use the Yii-Bootstrap extension. (http://www.cniska.net/yii-bootstrap/) Edward you'll like this. So I have the following code: Which lies within a <?php $form=$this->beginWidget('CActiveForm', array( 'id'=>'feedback-form', 'enableClientValidation'=>true, 'clientOptions'=>array( 'validateOnSubmit'=>true, ), )); ?> <?php echo $form->errorSummary($model); ?> <div class="row"> <?php echo $form->labelEx($model,''); ?> <?php echo $form->textField($model,'name', array('placeholder'=>'Name')); ?> </div> // more code <div class="btn-group" data-toggle="buttons-radio"> <?php echo $form->labelEx($model,'satisfaction') . "\n"; ?> <?php $this->widget('bootstrap.widgets.TbButtonGroup', array( 'type' => 'info', 'toggle' => 'radio', // 'checkbox' or 'radio' 'buttonType' => 'button', 'buttons' => array( array('label'=>'1'), array('label'=>'2'), array('label'=>'3'), array('label'=>'4'), array('label'=>'5'), array('label'=>'6'), array('label'=>'7'), array('label'=>'8'), array('label'=>'9'), array('label'=>'10'), ), )); ?> Lovely, the form displays properly. But I'm not sure how I can tie the input from the satisfaction rating to the form for processing. The HTML generated looks like this: <div class="btn-group" data-toggle="buttons-radio"> <label for="FeedbackForm_satisfaction" class="required">Satisfaction <span class="required">*</span></label> <div class="btn-group" data-toggle="buttons-radio"> <button class="btn btn-info" name="yt0" type="button">1</button> <button class="btn btn-info" name="yt1" type="button">2</button> <button class="btn btn-info" name="yt2" type="button">3</button> <button class="btn btn-info" name="yt3" type="button">4</button> <button class="btn btn-info" name="yt4" type="button">5</button> <button class="btn btn-info" name="yt5" type="button">6</button> <button class="btn btn-info" name="yt6" type="button">7</button> <button class="btn btn-info" name="yt7" type="button">8</button> <button class="btn btn-info" name="yt8" type="button">9</button> <button class="btn btn-info" name="yt9" type="button">10</button> </div> </div> </div> To me this part of the form seems to be void of a value input. I'd expect some kind of name="FeedbackForm[satisfaction]". So I guess I'm wondering, what am I missing here OR is it easier just to try and style the radio buttons another way? I feel like I need to make reference to $form.. Thanks Jonathon
  10. Jonathon

    Clips

    Yes possibly. In that case I'll await Chapter 12 of Larry's book
  11. Jonathon

    Clips

    Well it is currently in my layout file. I just thought it would be cleaner HTML wise in the view to call it from another place as it's not going to be used on every page. I'll keep it where it is. I did read that clips were more appropriate for dynamic content. Thanks for getting back to me Jonathon
  12. I don't think so Larry. I think I've found the solution. From what I've detailed if there was anything wrong I'm sure yourself or Thomas would have caught it. Thanks for everyone's help Jonathon
  13. Jonathon

    Clips

    Hi, I'm going to have some rotating banners on some of my pages. As they are only on some of my pages I didn't want to include this in my layout. I thought placing them in a clip would be a good idea and then just rendering them in the view file. Is it?
  14. It was pretty straight forward to just copy and edit the ContacfForm code. I want to use Bootsrap with my forms though, so I was reading up about that. Some pople suggest extending CForm which I might have a go at. I will have a fare few forms.
  15. Thanks Larry, I did see in your book the piece on ContactForm and thought it must be similar. Yes it looks like a button, I think that part is where I confused people (sorry). Thanks
  16. I may have confused you Thomas. I have a button on every page (Send Feedback). Currently that button takes me to a static page called feedback.php which is where the form is.
  17. I don't really follow Thomas, sorry. If I can explain it, I just have a feedback button that appears on every page. Currently, I decided to link this to a static page (feedback.php). But i'm not sure where I should put handling the submission, validation and sending the feedback to an email address?
  18. Hi, I've read the piece on forms. I am wanting to implement a feedback button that will appear on each page. I'm just thinking as there is no model where is the ideal place for the code for it to go? The SiteController is what i'm thinking, only because it's the default controller. Just wanted some thoughts. Thanks Jonathon
  19. Ok, i'll look at doing that. The main thing for me is that you can use them this way. Thanks
  20. Hi, I have been just playing around with Yii and querying Databases. A couple of things struck me in the last few minutes. I've been trying to get all the information I want to get over to the view in one fell swoop (1 model). Which is what I think hindered my initial work. For instance this is some code from one of my controllers public function actionIndex($id) { $companyItems = Company::model()->returnCompanyItemListings($id); // This model method returns the items listed by a company $this->render('index', array( 'model'=>$companyItems, )); } It works fine and returns the information I want back. (It's actually a fairly complex three table join using DAO). Then ran into a similar problem as before. I can only use this information once in the foreach loop. I then remembered some code in another controller about loading models that I used. (It's actually the code for loadModel(). I then updated my code in the controller to this: public function actionIndex($id) { $companyItems = Company::model()->returnCompanyItemListings($id); // This model method returns the items data $model = Company::model()->findByPk($id); $this->render('index', array( 'model'=>$companyItems, 'model2'=>$model, )); } So by passing 2 models I can use one $model2->name to echo out the company on the company listing page and it will be dynamically adjusted. I can then use $model in the foreach loop to get the items data. Is that acceptable?? Because if so. It's been a decent discovery for me and something I hadn't put together from the book. Jonathon
  21. Hi Thomas, I am actually Jonathon Yes, I'm going to take your approach and try that. I am doing Larry's project in the Yii book. But also I am just doing my own practice project too at the same time to practice and get more familiar with Yii. Things sound simple when read, but unless I need to do exactly what's in the book I'm not 100% sure of how to do things. So I thought this would be a good way to practice and experiment whilst having guidance through the book too. I will do my best to report back on any solutions or ideas I come across. Thanks for your help!
  22. I believe you're right in that AR return LEFT OUTER joins. Thanks Thomas.
×
×
  • Create New...