Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.get('/sample-edit/:cid',
- setRender('dashboard/sample-edit.hbs'),
- setRedirect({auth: '/'}),
- isAuthenticated,
- users.getSampleEdit);
- var userSchema = new mongoose.Schema({
- email: { type: String, unique: true, lowercase: true },
- password: String,
- profile: {
- name: { type: String, default: '' },
- location: { type: String, default: '' }
- },
- image: {
- path: { type: String, default: '' },
- },
- sample:
- [{
- name: String,
- description: String,
- purchase: String,
- brand: String,
- material: String,
- notes: String,
- qty: String,
- imgpath: String,
- }],
- resetPasswordToken: String,
- resetPasswordExpires: Date
- });
- exports.getSampleEdit = function(req, res, next){
- User.findById(req.user.id, { sample: { $elemMatch: { _id: ObjectId } } },
- function(err, user) {
- if (err) return next(err);
- var form = {},
- error = null,
- formFlash = req.flash('form'),
- errorFlash = req.flash('error');
- if (formFlash.length) {
- form.email = formFlash[0].email;
- }
- if (errorFlash.length) {
- error = errorFlash[0];
- }
- res.render(req.render, {user: req.user, form: form, error: error});
- console.log(req.params.id)
- });
- };
- <form action="/user/sample" method="POST" class="form-horizontal">
- <div class="form-group">
- <label for="name" class="col-sm-3 control-label">Sample Name:</label>
- <div class="col-lg-offset-3 col-sm-4"><input type="text" name="name" id="name" value="{{sample.name}}" class="form-control"></div>
- </div>
- <div class="form-group">
- <label for="description" class="col-sm-3 control-label">Description:</label>
- <div class="col-sm-4"><input type="text" name="description" id="description" value="{{sample.description}}" class="form-control"></div>
- </div>
- <div class="form-group">
- <label for="description" class="col-sm-3 control-label">Where did you buy it from?</label>
- <div class="col-sm-4"><input type="text" name="purchase" id="purchase" value="{{sample.purchase}}" class="form-control"></div>
- </div>
- <div class="form-group">
- <label for="description" class="col-sm-3 control-label">Brand:</label>
- <div class="col-sm-4"><input type="text" name="brand" id="brand" value="{{sample.brand}}" class="form-control"></div>
- </div>
- <div class="form-group">
- <label for="description" class="col-sm-3 control-label">Material:</label>
- <div class="col-sm-4"><input type="text" name="material" id="material" value="{{sample.material}}" class="form-control"></div>
- </div>
- <div class="form-group">
- <label for="description" class="col-sm-3 control-label">Notes:</label>
- <div class="col-sm-4"><input type="text" name="notes" id="notes" value="{{sample.notes}}" class="form-control"></div>
- </div>
- <div class="form-group">
- <label for="description" class="col-sm-3 control-label">How much sample do you have?</label>
- <div class="col-sm-4"><input type="text" name="qty" id="qty" value="{{sample.qty}}" class="form-control"></div>
- </div>
- <div class="form-group">
- <label for="description" class="col-sm-3 control-label">Image</label>
- <div class="col-sm-4"><input type="text" name="imgpath" id="imgpath" value="{{sample.imgpath}}" class="form-control"></div>
- </div>
- <div class="form-group">
- <div class="col-sm-offset-3 col-sm-4"><button type="submit" class="btn btn-primary"><span class="ion-edit"></span>Save Sample</button></div>
- </div>
- </form>
Add Comment
Please, Sign In to add comment