Welcome Guest, Not a member yet? Register   Sign In
Routing Issue: Optional ID and Named Routes in CodeIgniter 4
#2

(This post was last modified: 03-26-2025, 07:10 AM by luckmoshy.)

how doyou call your form to route maybe this can at least give an good eye
Code:
action="url_to('edit', $product['id'])"
Code:
action="route_to('edit', $product['id'])"
Code:
action="base_url('edit/'.product[id])

fetch
Code:
edit/productId

and your contr shoul be
PHP Code:
public function edit($id null)
{
    if (
$this->request->is'post')) {
        
// Process form submission
    
}

    if (
$id) {
        
// Load post for editing
    
} else {
        
// Create new post
    
}

    return 
view('post_form', ['id' => $id]);

Codeigniter First, Codeigniter Then You!!
yekrinaDigitals

Reply


Messages In This Thread
RE: Routing Issue: Optional ID and Named Routes in CodeIgniter 4 - by luckmoshy - 03-26-2025, 07:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB